CCG.CQRS.Tests 1.0.7

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package CCG.CQRS.Tests --version 1.0.7
NuGet\Install-Package CCG.CQRS.Tests -Version 1.0.7
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="CCG.CQRS.Tests" Version="1.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CCG.CQRS.Tests --version 1.0.7
#r "nuget: CCG.CQRS.Tests, 1.0.7"
#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 CCG.CQRS.Tests as a Cake Addin
#addin nuget:?package=CCG.CQRS.Tests&version=1.0.7

// Install CCG.CQRS.Tests as a Cake Tool
#tool nuget:?package=CCG.CQRS.Tests&version=1.0.7

Usage

The new Mock<PipDbContext>().WithDbSets() extension method setups Mock<DbSet>() for all the DbSets on the DbContext.

Support methods are:

  • DbContext
    • Set<T>
    • DbSet properties
  • DbSet
    • Add(T model)
    • Remove(T model)
    • AddRange(IEnumerable<T> list)
    • RemoveRange(IEnumerable<T> list)
    • Find() for CCG.CQRS.DataModel.IEntity
    • Include(string)

To get access to a fixture you can use the MockContextHelpers.CreateFixture() static method.

Examples

private Mock<PipDbContext> _db;
private AddEmployeeCommandValidator _validator;
private AddEmployeeHandler _handler;

[TestInitialize]
public void Setup()
{
    // mock entity framework db context.
    // WithDbSets() will create mock dbsets for all DbSets on context
    _db = new Mock<PipDbContext>().WithMockDbSets();
   
     //  extension method CreateEntities(n) will create n fake entities with autofixture
    Mock.Get(_db.Object.PhoneNumberTypes).CreateEntities(3);

    _validator = new AddEmployeeCommandValidator(_db.Object);
    _handler = new AddEmployeeHandler(_db.Object);
}

Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.8-r28 762 6/28/2018
1.0.7 6,291 5/1/2018
1.0.6 953 3/21/2018
1.0.5 848 3/21/2018
1.0.4 863 3/19/2018
1.0.3 897 3/19/2018
1.0.2 943 3/19/2018
1.0.1 954 3/14/2018
1.0.0 966 3/14/2018