public void SutIsIdiomaticAssertion()
 {
     // Fixture setup
     // Exercise system
     var sut = new CompositeIdiomaticAssertion();
     // Verify outcome
     Assert.IsAssignableFrom<IIdiomaticAssertion>(sut);
     // Teardown
 }
 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 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 ConstructedWithEnumerableIdiomaticAssertionsIsCorrect()
        {
            // Fixture setup
            IEnumerable<IIdiomaticAssertion> assertions = new[]
            {
                new DelegatingIdiomaticAssertion(),
                new DelegatingIdiomaticAssertion(),
                new DelegatingIdiomaticAssertion()
            }.AsEnumerable();

            var sut = new CompositeIdiomaticAssertion(assertions);
            // Exercise system
            var result = sut.Assertions;
            // Verify outcome
            Assert.True(assertions.SequenceEqual(result));
            // 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 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 (Ploeh.TestTypeFoundation.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 VerifyEnumerablePropertyInfoVerifiesAllIdiomaticAssertions()
        {
            // Fixture setup
            var observedProperties = new List<IEnumerable<PropertyInfo>>();
            var expectations = Enumerable.Repeat(
                new DelegatingIdiomaticAssertion {OnPropertyInfosVerify = observedProperties.Add}, 3)
                .ToArray();

            var sut = new CompositeIdiomaticAssertion(expectations);
            IEnumerable<PropertyInfo> properties = new[]
            {
                typeof (Ploeh.TestTypeFoundation.AbstractType).GetProperties().First(),
                typeof (System.String).GetProperties().First(),
            }
                .AsEnumerable();

            // Exercise system
            sut.Verify(properties);
            // Verify outcome
            Assert.Equal(expectations.Length, observedProperties.Count(properties.Equals));
            // Teardown
        }
        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 (Ploeh.TestTypeFoundation.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 (Ploeh.TestTypeFoundation.AbstractType).Assembly,
                typeof (System.String).Assembly,
            };

            // Exercise system
            sut.Verify(assemblies);
            // Verify outcome
            Assert.Equal(expectations.Length, observedAssemblies.Count(assemblies.Equals));
            // Teardown
        }
        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 (Ploeh.TestTypeFoundation.AbstractType);
            // Exercise system
            sut.Verify(type);
            // Verify outcome
            Assert.Equal(expectations.Length, observedTypes.Count(type.Equals));
            // Teardown
        }
 public BasicEqualityRulesAssertion(IEnumerable <IIdiomaticAssertion> idiomaticAssertions)
 {
     this.compositeIdiomaticAssertion = new CompositeIdiomaticAssertion(idiomaticAssertions);
 }
示例#14
0
        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 BasicEqualityRulesAssertion(IEnumerable<IIdiomaticAssertion> idiomaticAssertions)
 {
     this.compositeIdiomaticAssertion = new CompositeIdiomaticAssertion(idiomaticAssertions);
 }