コード例 #1
0
        private void We_tell_the_comparator_to_use_that_on_a_specific_object_when_comparing_two_lists()
        {
            var aList = new List <ObjectWithValueTypeProperties>
            {
                new ObjectWithValueTypeProperties(),
                new ObjectWithValueTypeProperties(),
                new ObjectWithValueTypeProperties()
            };
            var anotherList = new List <ObjectWithValueTypeProperties>
            {
                new ObjectWithValueTypeProperties(),
                new ObjectWithValueTypeProperties {
                    MyBoolean = true
                },
                new ObjectWithValueTypeProperties {
                    MyBoolean = true
                }
            };

            aList.ShouldNotBeSameAs(anotherList);
            var test = new CharacterizationTest();

            test.Ignore(aList.ElementAt(1), booleanPropertySelector);
            test.Ignore(aList.ElementAt(2), booleanPropertySelector);
            test.CompareObjects(aList, anotherList);
        }
コード例 #2
0
        private void We_tell_the_comparator_to_use_that_on_all_elements_in_an_IEnumerable_when_comparing()
        {
            var aList = new List <ObjectWithValueTypeProperties>
            {
                new ObjectWithValueTypeProperties(),
                new ObjectWithValueTypeProperties {
                    MyInteger = 1
                },
                new ObjectWithValueTypeProperties {
                    MyInteger = 1
                }
            };
            var anotherList = new List <ObjectWithValueTypeProperties>
            {
                new ObjectWithValueTypeProperties(),
                new ObjectWithValueTypeProperties {
                    MyInteger = 1, MyBoolean = true
                },
                new ObjectWithValueTypeProperties {
                    MyInteger = 1, MyBoolean = true
                }
            };

            aList.ShouldNotBeSameAs(anotherList);
            var test = new CharacterizationTest();

            test.Ignore(aList.Where(o => o.MyInteger == 1), o => o.MyBoolean);
            test.CompareObjects(aList, anotherList);
        }
コード例 #3
0
        public CharacterizationTestBaseClassTest()
        {
            RecordingServices.RecordingSaver = new DoNotSaveRecordings();
            recorder = (DefaultRecorder)RecordingServices.Recorder;

            testClass   = new CharacterizationTest();
            writer      = new RecordingXmlWriter();
            addressBook = new SimpleAddressBook();
        }
コード例 #4
0
        private void We_use_that_lambda_representation_when_we_compare_two_objects_that_differ_on_that_property()
        {
            var someObject    = new ObjectWithValueTypeProperties();
            var anotherObject = new ObjectWithValueTypeProperties {
                MyBoolean = true
            };
            var test = new CharacterizationTest();

            test.IgnoreOnType(booleanPropertySelector);
            test.CompareObjects(someObject, anotherObject);
        }
コード例 #5
0
        private void We_tell_the_comparator_to_use_that_on_a_specific_object_when_comparing()
        {
            var anObject      = new ObjectWithValueTypeProperties();
            var anotherObject = new ObjectWithValueTypeProperties {
                MyBoolean = true
            };
            var test = new CharacterizationTest();

            test.Ignore(anObject, booleanPropertySelector);
            test.CompareObjects(anObject, anotherObject);
        }
コード例 #6
0
        private void We_do_the_comparison_on_two_slightly_different_objects_that_are_still_within_range()
        {
            var anObject      = new ObjectWithValueTypeProperties();
            var anotherObject = new ObjectWithValueTypeProperties {
                MyInteger = 9
            };
            var test = new CharacterizationTest();

            test.AllowOnType(integerPropertySelector, integerPropertyComparison);
            test.CompareObjects(anObject, anotherObject);
        }
コード例 #7
0
        private void We_use_that_lambda_representation_when_we_compare_two_objects_that_differ_on_underlying_properties()
        {
            var someObject = new ObjectWithMixedTypeProperties {
                MySimpleObject = new ObjectWithValueTypeProperties()
            };
            var anotherObject = new ObjectWithMixedTypeProperties
            {
                MySimpleObject = new ObjectWithValueTypeProperties
                {
                    MyBoolean = true,
                    MyDecimal = 1,
                    MyInteger = 1
                }
            };
            var test = new CharacterizationTest();

            test.IgnoreOnType(referenceTypePropertySelector);
            test.CompareObjects(someObject, anotherObject);
        }
コード例 #8
0
        private void We_try_to_ignore_on_that_unary_selector()
        {
            var test = new CharacterizationTest();

            thrownException = Record.Exception(() => test.IgnoreOnType(unarySelector));
        }