Exemple #1
0
 private static void AssertEqual <T>(T expectedEntity, T actualEntity)
 {
     Inspect
     .This(expectedEntity, actualEntity)
     .Report(Assert.True)
     .AreMemberWiseEqual();
 }
 public void NoDefaultValueIsGeneratedForNonIgnoredPrimitives()
 {
     Inspect
     .This(thing)
     .ForAll(
         pi => pi.Name != propertyInfo.Name || pi.DeclaringType != propertyInfo.DeclaringType,
         (pi, p) => Ensure.False(IsDefaultValue(p), pi.Name));
 }
 public void DefaultValueIsGeneratedForIgnoredPrimitives()
 {
     Inspect
     .This(thing)
     .ForAll(
         pi => pi.Name == propertyInfo.Name && pi.DeclaringType == propertyInfo.DeclaringType,
         (pi, p) => Ensure.True(IsDefaultValue(p), pi.Name));
 }
 public void NoDefaultValueIsGenerated_ExceptForBools()
 {
     Inspect
     .This(thing)
     .ForAllPrimitives(
         pi => pi.PropertyType == typeof(bool),
         (pi, p) => Ensure.False(IsDefaultValue(p), pi.Name));
 }
 public void NoEmptyStringIsGenerated()
 {
     Inspect
     .This(thing)
     .ForAllPrimitives(
         pi => pi.PropertyType == typeof(string),
         p => Ensure.NotEqual(String.Empty, p));
 }
 public Spec TheDefaultStringValueIsNull()
 {
     return(new Spec(
                () => Inspect
                .This(thing)
                .ForAll(
                    pi => pi.Name == propertyInfo.Name && pi.DeclaringType == propertyInfo.DeclaringType,
                    (pi, p) => Ensure.Null(p, pi.Name)))
            .If(() => propertyInfo.PropertyType == typeof(string)));
 }
        public void ForAllStrings()
        {
            var thing = new Something {
                MyIntProp = 42, MyStringProp = "ne string"
            };
            var inspector = Inspect.This(thing);
            var list      = new List <object>();

            inspector.ForAll(pi => pi.PropertyType == typeof(string), list.Add);
            Assert.Equal(1, list.Count);
            Assert.Equal("ne string", list[0]);
        }
        public void ForAllPrimitives()
        {
            var thing = new Something {
                MyIntProp = 42, MyStringProp = "ne string"
            };
            var inspector = Inspect.This(thing);
            var list      = new List <object>();

            inspector.ForAllPrimitives(list.Add);
            Assert.Equal(2, list.Count);
            Assert.Equal(42, list[0]);
            Assert.Equal("ne string", list[1]);
        }
        public void ForAll()
        {
            var somethingElse = new SomethingElse();
            var thing         = new Something {
                MyIntProp = 42, MyStringProp = "ne string", MySomethingElse = somethingElse
            };
            var inspector = Inspect.This(thing);
            var list      = new List <object>();

            inspector.ForAll(list.Add);
            Assert.Equal(3, list.Count);
            Assert.Contains(42, list);
            Assert.Contains("ne string", list);
            Assert.Contains(somethingElse, list);
        }
        public void IntTest()
        {
            var thingOne = new SomethingInt {
                MyProp = 42
            };
            var thingTwo = new SomethingInt {
                MyProp = 42
            };

            var inspector = Inspect.This(thingOne, thingTwo);

            Assert.True(inspector.AreMemberWiseEqual());

            thingTwo.MyProp = 43;

            Assert.False(inspector.AreMemberWiseEqual());
        }
Exemple #11
0
        public void CompositeTests()
        {
            var generator =
                new DomainGenerator()
                .With(42)
                .Component <SomethingElse>();
            var thingOne  = generator.One <Something>();
            var thingTwo  = generator.One <Something>();
            var inspector =
                Inspect
                .This(thingOne, thingTwo)
                .Inspect <Something, SomethingElse>(s => s.MySomethingElse);

            Assert.True(inspector.AreMemberWiseEqual());
            thingTwo.MySomethingElse.MyProp = 43;
            Assert.False(inspector.AreMemberWiseEqual());
        }
Exemple #12
0
        public void AreMemberWiseEqual()
        {
            var generator =
                new DomainGenerator()
                .With(42)
                .OneToMany <Something, SomethingElse>(3, (s, se) => s.MySomethingElse.Add(se));
            var thingOne  = generator.One <Something>();
            var thingTwo  = generator.One <Something>();
            var inspector =
                Inspect
                .This(thingOne, thingTwo)
                .Inspect <Something, SomethingElse>(s => s.MySomethingElse);

            Assert.True(inspector.AreMemberWiseEqual());
            thingTwo.MySomethingElse[1].MyProp = 43;
            Assert.False(inspector.AreMemberWiseEqual());
        }
        public void ReportResult()
        {
            var thingOne = new Something {
                MyProp = 42
            };
            var thingTwo = new Something {
                MyProp = 42
            };
            var inspector =
                Inspect
                .This(thingOne, thingTwo)
                .Report((b, m) => result = b);

            Assert.True(inspector.AreMemberWiseEqual());
            Assert.True(result);
            thingTwo.MyProp = 43;
            Assert.False(inspector.AreMemberWiseEqual());
            Assert.False(result);
        }
 public void NoNullValuesAreGenerated()
 {
     Inspect
     .This(thing)
     .ForAllPrimitives((pi, p) => Ensure.NotNull(p, pi.Name));
 }