public void GetDataReturnsCorrectResult() { // Fixture setup var method = typeof(TypeWithOverloadedMembers).GetMethod("DoSomething", new[] { typeof(object) }); var parameters = method.GetParameters(); var expectedResult = new object(); var builder = new DelegatingSpecimenBuilder { OnCreate = (r, c) => { Assert.Equal(parameters.Single(), r); Assert.NotNull(c); return(expectedResult); } }; var composer = new DelegatingFixture { OnCreate = builder.OnCreate }; var sut = new AutoDataAttribute(composer); // Exercise system var result = sut.GetData(method); // Verify outcome Assert.True(new[] { expectedResult }.SequenceEqual(result.Single())); // Teardown }
public void InitializedWithComposerHasCorrectComposer() { // Fixture setup var expectedComposer = new DelegatingFixture(); var sut = new AutoDataAttribute(expectedComposer); // Exercise system var result = sut.Fixture; // Verify outcome Assert.Equal(expectedComposer, result); // Teardown }
public void GetDataOrdersCustomizationAttributes(string methodName) { // Fixture setup var method = typeof(TypeWithCustomizationAttributes).GetMethod(methodName, new[] { typeof(ConcreteType) }); var customizationLog = new List <ICustomization>(); var fixture = new DelegatingFixture(); fixture.OnCustomize = c => { customizationLog.Add(c); return(fixture); }; var sut = new AutoDataAttribute(fixture); // Exercise system sut.GetData(method); // Verify outcome Assert.False(customizationLog[0] is FreezeOnMatchCustomization); Assert.True(customizationLog[1] is FreezeOnMatchCustomization); // Teardown }