public void GetDataOrdersCustomizationAttributes(string methodName) { // Fixture setup var method = typeof(TypeWithCustomizationAttributes).GetMethod(methodName, new[] { typeof(ConcreteType) }); var parameters = method.GetParameters(); var parameterTypes = (from pi in parameters select pi.ParameterType).ToArray(); 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, parameterTypes); // Verify outcome Assert.False(customizationLog[0] is FreezeOnMatchCustomization); Assert.True(customizationLog[1] is FreezeOnMatchCustomization); // Teardown }
/// <summary> /// Initializes a new instance of the <see cref="InlineNullRegisterAutoDataAttribute"/> class. /// </summary> /// <param name="autoDataAttribute">The <see cref="AutoDataAttribute"/> instance that provides auto-generated data specimens.</param> /// <param name="parameterName">Name of the null parameter.</param> public InlineNullRegisterAutoDataAttribute( AutoDataAttribute autoDataAttribute, string parameterName) : base(autoDataAttribute) { _parameterName = parameterName; }
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 GetArgumentsWithNullMethodThrows() { // Arrange var sut = new AutoDataAttribute(); // Act & Assert Assert.Throws <ArgumentNullException>(() => sut.GetData(null)); }
public void SutIsDataAttribute() { // Fixture setup // Exercise system var sut = new AutoDataAttribute(); // Verify outcome Assert.IsAssignableFrom<DataAttribute>(sut); // Teardown }
public void SutIsDataAttribute() { // Arrange // Act var sut = new AutoDataAttribute(); // Assert Assert.IsAssignableFrom <DataAttribute>(sut); }
public void SutIsDataAttribute() { // Arrange // Act var sut = new AutoDataAttribute(); // Assert Assert.IsInstanceOf <DataAttribute>(sut); }
public void GetDataWithNullMethodThrows() { // Arrange var sut = new AutoDataAttribute(); var dummyTypes = Type.EmptyTypes; // Act & assert Assert.Throws <ArgumentNullException>(() => sut.GetData(null)); }
public void GetArgumentsWithNullMethodThrows() { // Fixture setup var sut = new AutoDataAttribute(); // Exercise system and verify outcome Assert.Throws <ArgumentNullException>(() => sut.GetData(null)); // Teardown }
public void AutoDataAttributeUsesRealValueByDefault() { // Arrange // Act var sut = new AutoDataAttribute(); // Assert Assert.That(sut.TestMethodBuilder, Is.TypeOf <FixedNameTestMethodBuilder>()); }
public void SutIsDataAttribute() { // Fixture setup // Exercise system var sut = new AutoDataAttribute(); // Verify outcome Assert.IsAssignableFrom <DataAttribute>(sut); // Teardown }
public void InitializedWithDefaultConstructorHasCorrectFixture() { // Fixture setup var sut = new AutoDataAttribute(); // Exercise system IFixture result = sut.Fixture; // Verify outcome Assert.IsAssignableFrom<Fixture>(result); // Teardown }
public void SutIsDataAttribute() { // Fixture setup // Exercise system var sut = new AutoDataAttribute(); // Verify outcome Assert.IsInstanceOfType(sut, typeof(DataAttribute)); // Teardown }
public void AutoDataAttributeIsCorrectWhenCreatedExplicitlyByConstructor() { // Arrange var expected = new AutoDataAttribute(); var sut = new DerivedInlineAutoDataAttribute(expected); // Act var result = sut.AutoDataAttribute; // Assert Assert.Equal(expected, result); }
public void ExecuteShouldAutoGenerateReferenceTypeArgument(AutoDataAttribute sut) { // Arrange // Act // Assert Assert.IsNotNull(sut); }
public void AttributesContainsAttributeWhenConstructedWithExplicitAutoDataAttribute() { // Arrange var autoDataAttribute = new AutoDataAttribute(); var sut = new DerivedInlineAutoDataAttribute(autoDataAttribute); // Act var result = sut.Attributes; // Assert Assert.Contains(autoDataAttribute, result); }
public void InitializedWithDefaultConstructorHasCorrectFixture() { // Fixture setup var sut = new AutoDataAttribute(); // Exercise system IFixture result = sut.Fixture; // Verify outcome Assert.IsInstanceOfType(result, typeof(Fixture)); // Teardown }
public void AutoDataAttributeUsesRealValueByDefault() { // Fixture setup // Exercise system var sut = new AutoDataAttribute(); // Verify outcome Assert.That(sut.TestMethodBuilder, Is.TypeOf <FixedNameTestMethodBuilder>()); // Teardown }
public void ExecuteShouldAutoGenerateReferenceTypeArgument(AutoDataAttribute sut) { // Arrange // Act // Assert sut.ShouldNotBeNull(); }
public void InitializedWithCorrectComposerTypeHasCorrectComposer() { // Arrange var composerType = typeof(DelegatingFixture); var sut = new AutoDataAttribute(composerType); // Act var result = sut.Fixture; // Assert Assert.IsAssignableFrom(composerType, result); }
public void FixtureTypeIsCorrect() { // Arrange var composerType = typeof(DelegatingFixture); var sut = new AutoDataAttribute(composerType); // Act var result = sut.FixtureType; // Assert Assert.Equal(composerType, result); }
public void AutoDataAttributeIsCorrectWhenCreatedWithModestConstructor() { // Fixture setup var sut = new InlineAutoDataAttribute(); // Exercise system AutoDataAttribute result = sut.AutoDataAttribute; // Verify outcome Assert.NotNull(result); // Teardown }
public void InitializedWithDefaultConstructorHasCorrectFixture() { // Fixture setup var sut = new AutoDataAttribute(); // Exercise system IFixture result = sut.Fixture; // Verify outcome Assert.IsAssignableFrom <Fixture>(result); // 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 AttributesContainsAttributeWhenConstructedWithExplicitAutoDataAttribute() { // Fixture setup var autoDataAttribute = new AutoDataAttribute(); var sut = new InlineAutoDataAttribute(autoDataAttribute); // Exercise system var result = sut.Attributes; // Verify outcome Assert.Contains(autoDataAttribute, result); // Teardown }
public void InitializedWithDefaultConstructorHasCorrectFixture() { // Arrange var sut = new AutoDataAttribute(); // Act #pragma warning disable 618 IFixture result = sut.Fixture; #pragma warning restore 618 // Assert Assert.IsAssignableFrom <Fixture>(result); }
public void ValuesAreCorrectWhenConstructedWithExplicitAutoDataAttribute() { // Arrange var dummyAutoDataAttribute = new AutoDataAttribute(); var expectedValues = new[] { new object(), new object(), new object() }; var sut = new DerivedInlineAutoDataAttribute(dummyAutoDataAttribute, expectedValues); // Act var result = sut.Values; // Assert Assert.True(expectedValues.SequenceEqual(result)); }
public void InitializedWithCorrectComposerTypeHasCorrectComposer() { // Fixture setup var composerType = typeof(DelegatingFixture); var sut = new AutoDataAttribute(composerType); // Exercise system var result = sut.Fixture; // Verify outcome Assert.IsAssignableFrom(composerType, result); // Teardown }
public void FixtureTypeIsCorrect() { // Fixture setup var composerType = typeof(DelegatingFixture); var sut = new AutoDataAttribute(composerType); // Exercise system var result = sut.FixtureType; // Verify outcome Assert.Equal(composerType, result); // Teardown }
public void AttributesContainsCorrectAttributeTypesWhenConstructorWithExplicitAutoDataAttribute() { // Arrange var autoDataAttribute = new AutoDataAttribute(); var sut = new InlineAutoDataAttribute(autoDataAttribute); // Act var result = sut.Attributes; // Assert var expected = new[] { typeof(InlineDataAttribute), autoDataAttribute.GetType() }; Assert.True(result.Select(d => d.GetType()).SequenceEqual(expected)); }
public void AttributesContainsAttributeWhenConstructedWithExplicitAutoDataAttribute() { // Fixture setup var autoDataAttribute = new AutoDataAttribute(); var sut = new InlineAutoDataAttribute(autoDataAttribute); // Exercise system var result = sut.Attributes; // Verify outcome Assert.Contains(autoDataAttribute, result); // Teardown }
public void AttributesContainsCorrectAttributeTypesWhenConstructorWithExplicitAutoDataAttribute() { // Fixture setup var autoDataAttribute = new AutoDataAttribute(); var sut = new InlineAutoDataAttribute(autoDataAttribute); // Exercise system var result = sut.Attributes; // Verify outcome var expected = new[] { typeof(InlineDataAttribute), autoDataAttribute.GetType() }; Assert.True(result.Select(d => d.GetType()).SequenceEqual(expected)); // 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 AutoDataAttributeIsCorrectWhenCreatedExplicitlyByConstructor() { // Fixture setup var expected = new AutoDataAttribute(); var sut = new InlineAutoDataAttribute(expected); // Exercise system var result = sut.AutoDataAttribute; // Verify outcome Assert.Equal(expected, result); // Teardown }
public void ValuesAreCorrectWhenConstructedWithExplicitAutoDataAttribute() { // Fixture setup var dummyAutoDataAttribute = new AutoDataAttribute(); var expectedValues = new[] { new object(), new object(), new object() }; var sut = new InlineAutoDataAttribute(dummyAutoDataAttribute, expectedValues); // Exercise system var result = sut.Values; // Verify outcome Assert.True(expectedValues.SequenceEqual(result)); // Teardown }
public void BuildFromYieldsRunnableTestMethod() { // Arrange var autoDataAttribute = new AutoDataAttribute(); var fixtureType = this.GetType(); var methodWrapper = new MethodWrapper(fixtureType, fixtureType.GetMethod("DummyTestMethod")); var testSuite = new TestSuite(fixtureType); // Act var testMethod = autoDataAttribute.BuildFrom(methodWrapper, testSuite).First(); // Assert Assert.That(testMethod.RunState == RunState.Runnable); }
public void InitializedWithCorrectComposerTypeHasCorrectComposer() { // Fixture setup var composerType = typeof(DelegatingFixture); var sut = new AutoDataAttribute(composerType); // Exercise system var result = sut.Fixture; // Verify outcome Assert.IsAssignableFrom(composerType, result); // Teardown }
public void FixtureTypeIsCorrect() { // Fixture setup var composerType = typeof(DelegatingFixture); #pragma warning disable 618 var sut = new AutoDataAttribute(composerType); #pragma warning restore 618 // Exercise system var result = sut.FixtureType; // Verify outcome Assert.AreEqual(composerType, result); // Teardown }
public void ImplementsITestBuilder() { var autoDataFixture = new AutoDataAttribute(); Assert.That(autoDataFixture, Is.InstanceOf<ITestBuilder>()); }
public void FixtureTypeIsCorrect() { // Fixture setup var composerType = typeof(DelegatingFixture); var sut = new AutoDataAttribute(composerType); // Exercise system var result = sut.FixtureType; // Verify outcome Assert.Equal(composerType, 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 }
public void GetDataWithNullMethodThrows() { // Fixture setup var sut = new AutoDataAttribute(); var dummyTypes = Type.EmptyTypes; // Exercise system and verify outcome Assert.Throws<ArgumentNullException>(() => sut.GetData(null, dummyTypes)); // Teardown }
public void ValuesAreCorrectWhenConstructedWithExplicitAutoDataAttribute() { // Fixture setup var dummyAutoDataAttribute = new AutoDataAttribute(); var expectedValues = new[] { new object(), new object(), new object() }; var sut = new InlineAutoDataAttribute(dummyAutoDataAttribute, expectedValues); // Exercise system var result = sut.Values; // Verify outcome Assert.True(expectedValues.SequenceEqual(result)); // Teardown }
public void GetDataReturnsCorrectResult() { // Fixture setup var method = typeof(TypeWithOverloadedMembers).GetMethod("DoSomething", new[] { typeof(object) }); var parameters = method.GetParameters(); var parameterTypes = (from pi in parameters select pi.ParameterType).ToArray(); 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 { OnCompose = () => builder }; var sut = new AutoDataAttribute(composer); // Exercise system var result = sut.GetData(method, parameterTypes); // Verify outcome Assert.True(new[] { expectedResult }.SequenceEqual(result.Single())); // Teardown }
public void AutoDataAttributeIsCorrectWhenCreatedExplicitlyByConstructor() { // Fixture setup var expected = new AutoDataAttribute(); var sut = new InlineAutoDataAttribute(expected); // Exercise system var result = sut.AutoDataAttribute; // Verify outcome Assert.Equal(expected, result); // Teardown }