ByteDecoder.ModelFactory 0.1.3

Install-Package ByteDecoder.ModelFactory -Version 0.1.3
dotnet add package ByteDecoder.ModelFactory --version 0.1.3
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.


.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

  • .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 198 7/29/2020
0.1.2 257 7/4/2020
0.1.1 232 6/29/2020
0.1.0 199 6/29/2020