本文整理汇总了C#中Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create方法的典型用法代码示例。如果您正苦于以下问题:C# CompositeSpecimenBuilder.Create方法的具体用法?C# CompositeSpecimenBuilder.Create怎么用?C# CompositeSpecimenBuilder.Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder
的用法示例。
在下文中一共展示了CompositeSpecimenBuilder.Create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateWillInvokeBuilderWithCorrectContainer
public void CreateWillInvokeBuilderWithCorrectContainer()
{
// Fixture setup
var expectedContainer = new DelegatingSpecimenContext();
var mockVerified = false;
var builderMock = new DelegatingSpecimenBuilder();
builderMock.OnCreate = (r, c) =>
{
Assert.Equal(expectedContainer, c);
mockVerified = true;
return new object();
};
var sut = new CompositeSpecimenBuilder(builderMock);
// Exercise system
var dummyRequest = new object();
sut.Create(dummyRequest, expectedContainer);
// Verify outcome
Assert.True(mockVerified, "Mock verification");
// Teardown
}
示例2: CreateWillReturnFirstSpecimenResultFromBuilders
public void CreateWillReturnFirstSpecimenResultFromBuilders()
{
// Fixture setup
var expectedResult = new object();
var builders = new ISpecimenBuilder[]
{
new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen() },
new DelegatingSpecimenBuilder { OnCreate = (r, c) => expectedResult },
new DelegatingSpecimenBuilder { OnCreate = (r, c) => new object() }
};
var sut = new CompositeSpecimenBuilder(builders);
// Exercise system
var anonymousRequest = new object();
var dummyContainer = new DelegatingSpecimenContext();
var result = sut.Create(anonymousRequest, dummyContainer);
// Verify outcome
Assert.Equal(expectedResult, result);
// Teardown
}
示例3: CreateWillReturnNoSpecimenIfAllBuildersReturnNoSpecimen
public void CreateWillReturnNoSpecimenIfAllBuildersReturnNoSpecimen()
{
// Fixture setup
var builders = new ISpecimenBuilder[]
{
new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen() },
new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen() },
new DelegatingSpecimenBuilder { OnCreate = (r, c) => new NoSpecimen() }
};
var sut = new CompositeSpecimenBuilder(builders);
// Exercise system
var anonymousRequest = new object();
var dummyContainer = new DelegatingSpecimenContext();
var result = sut.Create(anonymousRequest, dummyContainer);
// Verify outcome
#pragma warning disable 618
var expected = new NoSpecimen(anonymousRequest);
#pragma warning restore 618
Assert.Equal(expected, result);
// Teardown
}
示例4: CreateWillReturnNullIfAllBuildersReturnNull
public void CreateWillReturnNullIfAllBuildersReturnNull()
{
// Fixture setup
var builders = new ISpecimenBuilder[]
{
new DelegatingSpecimenBuilder { OnCreate = (r, c) => null },
new DelegatingSpecimenBuilder { OnCreate = (r, c) => null },
new DelegatingSpecimenBuilder { OnCreate = (r, c) => null }
};
var sut = new CompositeSpecimenBuilder(builders);
// Exercise system
var anonymousRequest = new object();
var dummyContainer = new DelegatingSpecimenContainer();
var result = sut.Create(anonymousRequest, dummyContainer);
// Verify outcome
Assert.IsNull(result, "Create");
// Teardown
}