本文整理汇总了C#中Fixture.Compose方法的典型用法代码示例。如果您正苦于以下问题:C# Fixture.Compose方法的具体用法?C# Fixture.Compose怎么用?C# Fixture.Compose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fixture
的用法示例。
在下文中一共展示了Fixture.Compose方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SingleParameterGetReturnsCorrectResult
public void SingleParameterGetReturnsCorrectResult(int number)
{
// Fixture setup
var fixture = new Fixture();
fixture.Inject(number);
var builder = fixture.Compose();
// Exercise system
var actual = builder.Get((int x) => -1 * x);
// Verify outcome
Assert.Equal(-1 * number, actual);
// Teardown
}
示例2: DoubleParameterGetReturnsCorrectResult
public void DoubleParameterGetReturnsCorrectResult(
int number,
string text)
{
// Fixture setup
var fixture = new Fixture();
fixture.Inject(number);
fixture.Inject(text);
var builder = fixture.Compose();
// Exercise system
var actual = builder.Get((int x, string y) => x + y);
// Verify outcome
Assert.Equal(number + text, actual);
// Teardown
}
示例3: DoubleParameterDoWillInvokeMethodWithCorrectParameters
public void DoubleParameterDoWillInvokeMethodWithCorrectParameters(
int expectedNumber,
string expectedText)
{
// Fixture setup
var fixture = new Fixture();
fixture.Inject(expectedNumber);
fixture.Inject(expectedText);
var builder = fixture.Compose();
var verified = false;
var mock = new CommandMock<int, string>();
mock.OnCommand = (x, y) => verified =
expectedNumber == x &&
expectedText == y;
// Exercise system
builder.Do((int x, string y) => mock.Command(x, y));
// Verify outcome
Assert.True(verified, "Mock wasn't verified.");
// Teardown
}
示例4: QuadrupleParameterDoWillInvokeMethodWithCorrectParameters
public void QuadrupleParameterDoWillInvokeMethodWithCorrectParameters(
int expectedNumber,
string expectedText,
Type expectedType,
bool expectedBool)
{
// Fixture setup
var fixture = new Fixture();
fixture.Inject(expectedNumber);
fixture.Inject(expectedText);
fixture.Inject(expectedType);
fixture.Inject(expectedBool);
var builder = fixture.Compose();
var verified = false;
var mock = new CommandMock<int, string, Type, bool>();
mock.OnCommand = (x, y, z, æ) => verified =
expectedNumber == x &&
expectedText == y &&
expectedType == z &&
expectedBool == æ;
// Exercise system
builder.Do(
(int x, string y, Type z, bool æ) => mock.Command(x, y, z, æ));
// Verify outcome
Assert.True(verified, "Mock wasn't verified.");
// Teardown
}
示例5: TripleParameterDoWillInvokeMethodWithCorrectParameters
public void TripleParameterDoWillInvokeMethodWithCorrectParameters(
string expectedText,
int expectedNumber,
bool expectedBool)
{
// Fixture setup
var fixture = new Fixture();
fixture.Inject(expectedText);
fixture.Inject(expectedNumber);
fixture.Inject(expectedBool);
var builder = fixture.Compose();
var verified = false;
var mock = new CommandMock<string, int, bool>();
mock.OnCommand = (x, y, z) => verified =
expectedText == x &&
expectedNumber == y &&
expectedBool == z;
// Exercise system
builder.Do((string x, int y, bool z) => mock.Command(x, y, z));
// Verify outcome
Assert.True(verified, "Mock wasn't verified.");
// Teardown
}
示例6: FixtureDoesNotHijackCollectionInterfacesIfAnotherCustomizationExistsForThem
public void FixtureDoesNotHijackCollectionInterfacesIfAnotherCustomizationExistsForThem(Type collectionInterface)
{
// Fixture setup
var fixture = new Fixture().Customize(new MultipleCustomization()).Customize(new AutoNSubstituteCustomization());
var context = new SpecimenContext(fixture.Compose());
// Exercise system
var result = context.Resolve(new SeededRequest(collectionInterface, null));
// Verify outcome
Assert.NotEmpty((IEnumerable)result);
}
示例7: ComposeWhenAutoPropertiesAreEnabledReturnsCorrectResult
public void ComposeWhenAutoPropertiesAreEnabledReturnsCorrectResult()
{
// Fixture setup
var sut = new Fixture();
// Exercise system
var result = sut.Compose();
// Verify outcome
var guard = Assert.IsAssignableFrom<RecursionGuard>(result);
var composedBuilders = Assert.IsAssignableFrom<CompositeSpecimenBuilder>(guard.Builder).ToList();
var customizer = Assert.IsAssignableFrom<CompositeSpecimenBuilder>(composedBuilders[0]);
Assert.True(sut.Customizations.SequenceEqual(customizer));
var postprocessor = Assert.IsAssignableFrom<Postprocessor>(composedBuilders[1]);
var engineAndMultiple = Assert.IsAssignableFrom<CompositeSpecimenBuilder>(postprocessor.Builder);
Assert.Same(sut.Engine, engineAndMultiple.First());
Assert.IsAssignableFrom<AnyTypeSpecification>(postprocessor.Specification);
var residueCollector = Assert.IsAssignableFrom<CompositeSpecimenBuilder>(composedBuilders[2]);
Assert.True(sut.ResidueCollectors.SequenceEqual(residueCollector));
Assert.IsAssignableFrom<TerminatingSpecimenBuilder>(composedBuilders[3]);
// Teardown
}
示例8: ComposeCorrectlyAppliesBehaviors
public void ComposeCorrectlyAppliesBehaviors()
{
// Fixture setup
var sut = new Fixture();
var comparer = new TaggedNodeComparer(new TrueComparer<ISpecimenBuilder>());
sut.Behaviors.Clear();
sut.Behaviors.Add(new DelegatingSpecimenBuilderTransformation { OnTransform = b => new TaggedNode(1, b) });
sut.Behaviors.Add(new DelegatingSpecimenBuilderTransformation { OnTransform = b => comparer.Equals(new TaggedNode(1), b) ? new TaggedNode(2, b) : new TaggedNode(3, b) });
// Exercise system
var result = sut.Compose();
// Verify outcome
Assert.Equal(new TaggedNode(2), result, comparer);
// Teardown
}
示例9: ComposeReturnsInstance
public void ComposeReturnsInstance()
{
// Fixture setup
var sut = new Fixture();
// Exercise system
var result = sut.Compose();
// Verify outcome
Assert.NotNull(result);
// Teardown
}
示例10: ComposeWhenAutoPropertiesAreOmittedReturnsCorrectResult
public void ComposeWhenAutoPropertiesAreOmittedReturnsCorrectResult()
{
// Fixture setup
var sut = new Fixture { OmitAutoProperties = true };
// Exercise system
var result = sut.Compose();
// Verify outcome
var guard = Assert.IsAssignableFrom<RecursionGuard>(result);
var composedBuilders = Assert.IsAssignableFrom<CompositeSpecimenBuilder>(guard.Builder).Builders.ToList();
var customizer = Assert.IsAssignableFrom<CompositeSpecimenBuilder>(composedBuilders[0]);
Assert.Equal(sut.Customizations, customizer.Builders);
Assert.Equal(sut.Engine, composedBuilders[1]);
var residueCollector = Assert.IsAssignableFrom<CompositeSpecimenBuilder>(composedBuilders[2]);
Assert.Equal(sut.ResidueCollectors, residueCollector.Builders);
Assert.IsAssignableFrom<TerminatingSpecimenBuilder>(composedBuilders[3]);
// Teardown
}
示例11: ComposeCorrectlyAppliesBehaviors
public void ComposeCorrectlyAppliesBehaviors()
{
// Fixture setup
var sut = new Fixture();
var builder1 = new DelegatingSpecimenBuilder();
var builder2 = new DelegatingSpecimenBuilder();
sut.Behaviors.Clear();
sut.Behaviors.Add(new DelegatingSpecimenBuilderTransformation { OnTransform = b => builder1 });
sut.Behaviors.Add(new DelegatingSpecimenBuilderTransformation { OnTransform = b => b == builder1 ? builder2 : new DelegatingSpecimenBuilder() });
// Exercise system
var result = sut.Compose();
// Verify outcome
Assert.Equal(builder2, result);
// Teardown
}
示例12: TripleParameterGetReturnsCorrectResult
public void TripleParameterGetReturnsCorrectResult(
string text,
bool logical,
long number)
{
// Fixture setup
var fixture = new Fixture();
fixture.Inject(text);
fixture.Inject(logical);
fixture.Inject(number);
var builder = fixture.Compose();
// Exercise system
var actual = builder.Get((string x, bool y, long z) => x + y + z);
// Verify outcome
Assert.Equal(text + logical + number, actual);
// Teardown
}
示例13: QuadrupleParameterGetReturnsCorrectResult
public void QuadrupleParameterGetReturnsCorrectResult(
Type type,
bool logical,
int number,
string text)
{
// Fixture setup
var fixture = new Fixture();
fixture.Inject(type);
fixture.Inject(logical);
fixture.Inject(number);
fixture.Inject(text);
var builder = fixture.Compose();
// Exercise system
var actual = builder.Get((Type x, bool y, int z, string æ) =>
x.ToString() + y + z + æ);
// Verify outcome
Assert.Equal(
type.ToString() + logical + number + text,
actual);
// Teardown
}