ByteDecoder.ModelFactory 0.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package ByteDecoder.ModelFactory --version 0.1.2                
NuGet\Install-Package ByteDecoder.ModelFactory -Version 0.1.2                
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.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ByteDecoder.ModelFactory --version 0.1.2                
#r "nuget: ByteDecoder.ModelFactory, 0.1.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. 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.2

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

.NET Core Build Status Maintainability

ModelFactory

Easy way to create Models for use in Test Suites

Targeted to .Net Core 3.1

Installation

Install the ModelFactory NuGet Package.

Package Manager Console

Install-Package ByteDecoder.ModelFactory

.NET Core CLI

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

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

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

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

  // Assert
  Assert.NotNull(models);
  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";
  });

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ByteDecoder/ModelFactory.

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

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
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 547 7/29/2020
0.1.2 508 7/4/2020
0.1.1 481 6/29/2020
0.1.0 440 6/29/2020