WS.Gen.ObjectMother
2.0.1
dotnet add package WS.Gen.ObjectMother --version 2.0.1
NuGet\Install-Package WS.Gen.ObjectMother -Version 2.0.1
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="WS.Gen.ObjectMother" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WS.Gen.ObjectMother" Version="2.0.1" />
<PackageReference Include="WS.Gen.ObjectMother" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WS.Gen.ObjectMother --version 2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: WS.Gen.ObjectMother, 2.0.1"
#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.
#:package WS.Gen.ObjectMother@2.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WS.Gen.ObjectMother&version=2.0.1
#tool nuget:?package=WS.Gen.ObjectMother&version=2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Object Mothers - Generate Builder Objects
For full information, please visit: https://github.com/WebbertSolutions/SourceGenerators/tree/main/Generators/GenerateObjectMother
Quick Start
Add namespace: using WS.Gen.ObjectMother;
Create a class in your test project
- Name doesn't matter
- "Builder" not required
Add attribute
Type should be your class you want a builder for
using WS.Gen.ObjectMother;
[ObjectMotherBuilder(typeof(Address), true)]
public partial class AddressBuilder
{
}
- Under your test project navigate down Anzlyzers → GenerateObjectMother → WS.Gen.ObjectMother.ObjectMotherGenerator
- Double click on your class builder.
- Copy the code at the bottom and paste into your class
public static AddressBuilder Required()
{
return new AddressBuilder()
.WithAddress1(() => xx)
.WithAddress2(() => xx)
.WithCity(() => xx)
.WithPostalCode(() => xx)
.WithState(() => xx)
;
}
public static AddressBuilder Typical()
{
return Required();
}
- Change the parameter value xx to suite your needs
- Add additional methods as needed
public static AddressBuilder BeverlyHills()
{
return new AddressBuilder()
.WithAddress1("123 Main Street")
.WithAddress2("Suite 200")
.WithCity("Beverly Hills")
.WithState(() => StateBuilder.Typical().WithName("CA").Build())
.WithPostalCode("90210")
;
}
There are no supported framework assets in this package.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.Bcl.HashCode (>= 1.1.1)
- Microsoft.CodeAnalysis.CSharp (>= 4.7.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.