public void VerifyCompositeEqualityBehaviourOnManyTypes() { IFixture fixture = new Fixture(); var equalityBehaviourAssertion = new CompositeIdiomaticAssertion( new EqualsNewObjectAssertion(fixture), new EqualsNullAssertion(fixture), new EqualsSelfAssertion(fixture), new EqualsSuccessiveAssertion(fixture)); var typesToExclude = new[] { // Needs parameters of type object to be IComparable typeof(Ploeh.AutoFixture.Kernel.RangedNumberRequest), // Constructors needs reflection types (e.g. ConstructorInfo, MethodInfo) typeof(Ploeh.AutoFixture.Kernel.ConstructorMethod), typeof(Ploeh.AutoFixture.Kernel.InstanceMethod), typeof(Ploeh.AutoFixture.Kernel.StaticMethod), // Autofixture can't create this typeof(Ploeh.AutoFixture.Kernel.NoSpecimen), }; var typesToVerify = typeof(IFixture).Assembly .GetExportedTypes() .Except(typesToExclude) .Where(t => !t.IsInterface && !t.IsAbstract); equalityBehaviourAssertion.Verify(typesToVerify); }
public void VerifyTypeCorrectlyVerifies( CompositeIdiomaticAssertion sut, Type type) { sut.Verify(type); foreach (var assertion in sut.Assertions) assertion.ToMock().Verify(x => x.Verify(type)); }
public void VerifyMemberCorrectlyVerifies( CompositeIdiomaticAssertion sut, MemberInfo member) { sut.Verify(member); foreach (var assertion in sut.Assertions) assertion.ToMock().Verify(x => x.Verify(member)); }
public void VerifyAssemblyCorrectlyVerifies( CompositeIdiomaticAssertion sut, Assembly assembly) { sut.Verify(assembly); foreach (var assertion in sut.Assertions) assertion.ToMock().Verify(x => x.Verify(assembly)); }
public void TwoSutAreEqual(IFixture fixture) { var assertion = new CompositeIdiomaticAssertion( new EqualsNullAssertion(fixture), new EqualsSelfAssertion(fixture), new EqualsNewObjectAssertion(fixture), new EqualsSuccessiveAssertion(fixture)); assertion.Verify(typeof(AddCmdApplicationConfigurationEvent)); }
public void ShouldHaveValueSemantics() { var fixture = new Fixture(); var equalitySemanticAssertion = new CompositeIdiomaticAssertion( new EqualsNewObjectAssertion(fixture), new EqualsNullAssertion(fixture), new EqualsSelfAssertion(fixture), new EqualsSuccessiveAssertion(fixture)); equalitySemanticAssertion.Verify(ValueTypes()); }
public void VerifyCompositeEqualityBehaviourOnManyTypes() { var fixture = _fixtureFactory(); var equalityBehaviourAssertion = new CompositeIdiomaticAssertion( new EqualsNewObjectAssertion(fixture), new EqualsNullAssertion(fixture), new EqualsSelfAssertion(fixture), new EqualsSuccessiveAssertion(fixture)); var typesToVerify = GetTypesToVerify(); equalityBehaviourAssertion.Verify(typesToVerify); }
public void VerifyTypeVerifiesAllIdiomaticAssertions() { // Arrange var observedTypes = new List <Type>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnTypeVerify = observedTypes.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); Type type = typeof(AbstractType); // Act sut.Verify(type); // Assert Assert.Equal(expectations.Length, observedTypes.Count(type.Equals)); }
public void VerifyAssemblyVerifiesAllIdiomaticAssertions() { // Arrange var observedAssemblies = new List <Assembly>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnAssemblyVerify = observedAssemblies.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); Assembly assembly = typeof(AbstractType).Assembly; // Act sut.Verify(assembly); // Assert Assert.Equal(expectations.Length, observedAssemblies.Count(assembly.Equals)); }
public void VerifyMethodInfoVerifiesAllIdiomaticAssertions() { // Arrange var observedMethods = new List <MethodInfo>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnMethodInfoVerify = observedMethods.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); Type typeWithMethod = typeof(TypeWithConcreteParameterMethod); MethodInfo method = typeWithMethod.GetMethods().First(); // Act sut.Verify(method); // Assert Assert.Equal(expectations.Length, observedMethods.Count(method.Equals)); }
public void VerifyConstructorInfoVerifiesAllIdiomaticAssertions() { // Arrange var observedConstructors = new List <ConstructorInfo>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnConstructorInfoVerify = observedConstructors.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); Type typeWithConstructor = typeof(UnguardedConstructorHost <object>); ConstructorInfo ctor = typeWithConstructor.GetConstructors().First(); // Act sut.Verify(ctor); // Assert Assert.Equal(expectations.Length, observedConstructors.Count(ctor.Equals)); }
public void VerifyAssemblyVerifiesAllIdiomaticAssertions() { // Fixture setup var observedAssemblies = new List <Assembly>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnAssemblyVerify = observedAssemblies.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); Assembly assembly = typeof(Ploeh.TestTypeFoundation.AbstractType).Assembly; // Exercise system sut.Verify(assembly); // Verify outcome Assert.Equal(expectations.Length, observedAssemblies.Count(assembly.Equals)); // Teardown }
public void VerifyPropertyInfoVerifiesAllIdiomaticAssertions() { // Arrange var observedProperties = new List <PropertyInfo>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnPropertyInfoVerify = observedProperties.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); Type typeWithMethod = typeof(PropertyHolder <object>); PropertyInfo property = typeWithMethod.GetProperties().First(); // Act sut.Verify(property); // Assert Assert.Equal(expectations.Length, observedProperties.Count(property.Equals)); }
public void VerifyTypeVerifiesAllIdiomaticAssertions() { // Fixture setup var observedTypes = new List <Type>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnTypeVerify = observedTypes.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); Type type = typeof(AbstractType); // Exercise system sut.Verify(type); // Verify outcome Assert.Equal(expectations.Length, observedTypes.Count(type.Equals)); // Teardown }
public void VerifyFieldInfoVerifiesAllIdiomaticAssertions() { // Arrange var observedFields = new List <FieldInfo>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnFieldInfoVerify = observedFields.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); Type typeWithField = typeof(FieldHolder <object>); FieldInfo field = typeWithField.GetFields().First(); // Act sut.Verify(field); // Assert Assert.Equal(expectations.Length, observedFields.Count(field.Equals)); }
public void VerifyCompositeEqualityBehaviourOnManyTypes() { IFixture fixture = new Fixture(); var equalityBehaviourAssertion = new CompositeIdiomaticAssertion( new EqualsNewObjectAssertion(fixture), new EqualsNullAssertion(fixture), new EqualsSelfAssertion(fixture), new EqualsSuccessiveAssertion(fixture)); var typesToExclude = new[] { // Needs parameters of type object to be IComparable typeof(RangedNumberRequest), // Needs parameters of type IMethod typeof(MissingParametersSupplyingMethod), // Constructors needs reflection types (e.g. ConstructorInfo, MethodInfo) typeof(ConstructorMethod), typeof(InstanceMethod), typeof(StaticMethod), // Autofixture interprets a value of this type as a creation // failure typeof(NoSpecimen), // Takes one or more values involving a generic type argument // in the constructor typeof(Criterion <>), typeof(FieldTypeAndNameCriterion), typeof(ParameterTypeAndNameCriterion), typeof(PropertyTypeAndNameCriterion), // Needs parameters to have the specific properties (max >= min). typeof(RangedSequenceRequest) }; var typesToVerify = typeof(IFixture).Assembly .GetExportedTypes() .Except(typesToExclude) .Where(t => !t.IsInterface && !t.IsAbstract); equalityBehaviourAssertion.Verify(typesToVerify); }
public void VerifyFieldInfoVerifiesAllIdiomaticAssertions() { // Fixture setup var observedFields = new List <FieldInfo>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnFieldInfoVerify = observedFields.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); Type typeWithField = typeof(Ploeh.TestTypeFoundation.FieldHolder <object>); FieldInfo field = typeWithField.GetFields().First(); // Exercise system sut.Verify(field); // Verify outcome Assert.Equal(expectations.Length, observedFields.Count(field.Equals)); // Teardown }
public void VerifyPropertyInfoVerifiesAllIdiomaticAssertions() { // Fixture setup var observedProperties = new List <PropertyInfo>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnPropertyInfoVerify = observedProperties.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); Type typeWithMethod = typeof(Ploeh.TestTypeFoundation.PropertyHolder <object>); PropertyInfo property = typeWithMethod.GetProperties().First(); // Exercise system sut.Verify(property); // Verify outcome Assert.Equal(expectations.Length, observedProperties.Count(property.Equals)); // Teardown }
public void VerifyMethodInfoVerifiesAllIdiomaticAssertions() { // Fixture setup var observedMethods = new List <MethodInfo>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnMethodInfoVerify = observedMethods.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); Type typeWithMethod = typeof(Ploeh.TestTypeFoundation.TypeWithConcreteParameterMethod); MethodInfo method = typeWithMethod.GetMethods().First(); // Exercise system sut.Verify(method); // Verify outcome Assert.Equal(expectations.Length, observedMethods.Count(method.Equals)); // Teardown }
public void VerifyConstructorInfoVerifiesAllIdiomaticAssertions() { // Fixture setup var observedConstructors = new List <ConstructorInfo>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnConstructorInfoVerify = observedConstructors.Add }, 3).ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); Type typeWithConstructor = typeof(Ploeh.TestTypeFoundation.UnguardedConstructorHost <object>); ConstructorInfo ctor = typeWithConstructor.GetConstructors().First(); // Exercise system sut.Verify(ctor); // Verify outcome Assert.Equal(expectations.Length, observedConstructors.Count(ctor.Equals)); // Teardown }
public void VerifyMemberInfoArrayVerifiesAllIdiomaticAssertions() { // Arrange var observedMemberInfoArrays = new List <MemberInfo[]>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnMemberInfoArrayVerify = observedMemberInfoArrays.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var members = new[] { typeof(AbstractType).GetMembers().First(), typeof(string).GetMembers().First(), }; // Act sut.Verify(members); // Assert Assert.Equal(expectations.Length, observedMemberInfoArrays.Count(members.Equals)); }
public void VerifyPropertyInfoArrayVerifiesAllIdiomaticAssertions() { // Arrange var observedPropertyArrays = new List <PropertyInfo[]>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnPropertyInfoArrayVerify = observedPropertyArrays.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var properties = new[] { typeof(AbstractType).GetProperties().First(), typeof(System.String).GetProperties().First(), }; // Act sut.Verify(properties); // Assert Assert.Equal(expectations.Length, observedPropertyArrays.Count(properties.Equals)); }
public void VerifyFieldInfoArrayVerifiesAllIdiomaticAssertions() { // Arrange var observedFieldArrays = new List <FieldInfo[]>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnFieldInfoArrayVerify = observedFieldArrays.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var fields = new[] { typeof(FieldHolder <object>).GetFields().First(), typeof(System.String).GetFields().First(), }; // Act sut.Verify(fields); // Assert Assert.Equal(expectations.Length, observedFieldArrays.Count(fields.Equals)); }
public void VerifyEnumerableTypesVerifiesAllIdiomaticAssertions() { // Arrange var observedTypes = new List <IEnumerable <Type> >(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnTypesVerify = observedTypes.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var assemblies = new[] { typeof(AbstractType), typeof(System.String), } .AsEnumerable(); // Act sut.Verify(assemblies); // Assert Assert.Equal(expectations.Length, observedTypes.Count(assemblies.Equals)); }
public void VerifyEnumerableConstructorInfoVerifiesAllIdiomaticAssertions() { // Arrange var observedConstructors = new List <IEnumerable <ConstructorInfo> >(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnConstructorInfosVerify = observedConstructors.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); IEnumerable <ConstructorInfo> ctors = new[] { typeof(ConcreteType).GetConstructors().First(), typeof(System.String).GetConstructors().First(), } .AsEnumerable(); // Act sut.Verify(ctors); // Assert Assert.Equal(expectations.Length, observedConstructors.Count(ctors.Equals)); }
public void VerifyMemberInfoArrayVerifiesAllIdiomaticAssertions() { // Fixture setup var observedMemberInfoArrays = new List <MemberInfo[]>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnMemberInfoArrayVerify = observedMemberInfoArrays.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var members = new[] { typeof(AbstractType).GetMembers().First(), typeof(System.String).GetMembers().First(), }; // Exercise system sut.Verify(members); // Verify outcome Assert.Equal(expectations.Length, observedMemberInfoArrays.Count(members.Equals)); // Teardown }
public void VerifyAssemblyArrayVerifiesAllIdiomaticAssertions() { // Fixture setup var observedAssemblies = new List <Assembly[]>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnAssemblyArrayVerify = observedAssemblies.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var assemblies = new Assembly[] { typeof(AbstractType).Assembly, typeof(System.String).Assembly, }; // Exercise system sut.Verify(assemblies); // Verify outcome Assert.Equal(expectations.Length, observedAssemblies.Count(assemblies.Equals)); // Teardown }
public void VerifyEnumerableMethodInfoVerifiesAllIdiomaticAssertions() { // Arrange var observedMethods = new List <IEnumerable <MethodInfo> >(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnMethodInfosVerify = observedMethods.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); IEnumerable <MethodInfo> methods = new[] { typeof(AbstractType).GetMethods().First(), typeof(System.String).GetMethods().First(), } .AsEnumerable(); // Act sut.Verify(methods); // Assert Assert.Equal(expectations.Length, observedMethods.Count(methods.Equals)); }
public void VerifyPropertyInfoArrayVerifiesAllIdiomaticAssertions() { // Fixture setup var observedPropertyArrays = new List <PropertyInfo[]>(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnPropertyInfoArrayVerify = observedPropertyArrays.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var properties = new[] { typeof(Ploeh.TestTypeFoundation.AbstractType).GetProperties().First(), typeof(System.String).GetProperties().First(), }; // Exercise system sut.Verify(properties); // Verify outcome Assert.Equal(expectations.Length, observedPropertyArrays.Count(properties.Equals)); // Teardown }
public void VerifyEnumerableFieldInfoVerifiesAllIdiomaticAssertions() { // Fixture setup var observedFields = new List <IEnumerable <FieldInfo> >(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnFieldInfosVerify = observedFields.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); IEnumerable <FieldInfo> fields = new[] { typeof(FieldHolder <object>).GetFields().First(), typeof(System.String).GetFields().First(), } .AsEnumerable(); // Exercise system sut.Verify(fields); // Verify outcome Assert.Equal(expectations.Length, observedFields.Count(fields.Equals)); // Teardown }
public void VerifyEnumerableMethodInfoVerifiesAllIdiomaticAssertions() { // Fixture setup var observedMethods = new List <IEnumerable <MethodInfo> >(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnMethodInfosVerify = observedMethods.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); IEnumerable <MethodInfo> methods = new[] { typeof(Ploeh.TestTypeFoundation.AbstractType).GetMethods().First(), typeof(System.String).GetMethods().First(), } .AsEnumerable(); // Exercise system sut.Verify(methods); // Verify outcome Assert.Equal(expectations.Length, observedMethods.Count(methods.Equals)); // Teardown }
public void VerifyEnumerableTypesVerifiesAllIdiomaticAssertions() { // Fixture setup var observedTypes = new List <IEnumerable <Type> >(); var expectations = Enumerable.Repeat( new DelegatingIdiomaticAssertion { OnTypesVerify = observedTypes.Add }, 3) .ToArray(); var sut = new CompositeIdiomaticAssertion(expectations); var assemblies = new[] { typeof(Ploeh.TestTypeFoundation.AbstractType), typeof(System.String), } .AsEnumerable(); // Exercise system sut.Verify(assemblies); // Verify outcome Assert.Equal(expectations.Length, observedTypes.Count(assemblies.Equals)); // Teardown }
private static void VerifyCompositeAssertion(CompositeIdiomaticAssertion compositeAssertion) { compositeAssertion.Verify(typeof(T)); compositeAssertion.Verify(typeof(T).GetEqualsMethod()); compositeAssertion.Verify(typeof(T).GetMethod("GetHashCode")); }