ByteDecoder.ModelFactory 0.1.3

.NET Core 3.1
dotnet add package ByteDecoder.ModelFactory --version 0.1.3
NuGet\Install-Package ByteDecoder.ModelFactory -Version 0.1.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ByteDecoder.ModelFactory" Version="0.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ByteDecoder.ModelFactory --version 0.1.3
#r "nuget: ByteDecoder.ModelFactory, 0.1.3"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install ByteDecoder.ModelFactory as a Cake Addin
#addin nuget:?package=ByteDecoder.ModelFactory&version=0.1.3

// Install ByteDecoder.ModelFactory as a Cake Tool
#tool nuget:?package=ByteDecoder.ModelFactory&version=0.1.3


.NET Core Build Status Maintainability Test Coverage

Easy way to create Models for use in Test Suites

Targeted to .Net Core 3.1


Install the ModelFactory NuGet Package.

Package Manager Console

Install-Package ByteDecoder.ModelFactory


dotnet add package ByteDecoder.ModelFactory

Examples and usage

An easy way to define data for models is to create in your test project, internal static classes that define custom data for your models, and then create instances of these model data templates for testing, minimizing code duplication, and maximizing extensibility and maintainability via the ModelFactory. It also takes the advantage of method group provided by C#.

You can create a single instance or a collection of a given type T

// Model Example

public class Command
  public int Id { get; set; }
  public string HowTo { get; set; }
  public string Platform { get; set; }
  public string CommandLine { get; set; }

// Data Template example method
internal static class CommandFactory
  internal static void BasicBuildOne(Command cmd)
    cmd.HowTo = "Do Something";
    cmd.Platform = "Some Platform";
    cmd.CommandLine = "Some Command";

// Now, creating model instances with ModelFactory

public void Create_ShouldCreateModel_WhenMethodIsProvided()
  // Arrange
  // Act
  var model = ModelFactory<Command>.Create(CommandFactory.BasicBuildOne);

  // Assert
  Assert.Equal("Do Something", model.HowTo);

public void Create_ShouldCreateCollection_WhenMethodIsProvided()
  // Arrange
  // Act
  var models = ModelFactory<Command>.Create(CommandFactory.BasicBuildOne, 2);

  // Assert
  Assert.Equal(2, models.Count());

// Also, you can define inline the model data as well
var model = ModelFactory<Command>.Create(m =>
    m.Id = 666;
    m.HowTo = "UPDATED";
    m.Platform = "UPDATED";
    m.CommandLine = "UPDATED";


Bug reports and pull requests are welcome on GitHub at

Copyright (c) 2020 Rodrigo Reyes released under the MIT license

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.3 387 7/29/2020
0.1.2 406 7/4/2020
0.1.1 370 6/29/2020
0.1.0 333 6/29/2020