WS.Gen.ObjectMother
1.0.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package WS.Gen.ObjectMother --version 1.0.3
NuGet\Install-Package WS.Gen.ObjectMother -Version 1.0.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="WS.Gen.ObjectMother" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WS.Gen.ObjectMother" Version="1.0.3" />
<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 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: WS.Gen.ObjectMother, 1.0.3"
#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@1.0.3
#: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=1.0.3
#tool nuget:?package=WS.Gen.ObjectMother&version=1.0.3
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 Typical()
{
return new AddressBuilder()
.WithAddress1(default(string))
.WithAddress2(default(string))
.WithCity(default(string))
.WithState(default(GenerateObjectMotherTest.Models.State))
.WithPostalCode(default(string))
;
}
- Change the parameter value default(string) 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)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.