public void BasicTypesDiffer()
        {
            BasicTypes leftObject = new BasicTypes()
            {
                BoolPrimitive   = false,
                BytePrimitive   = byte.MinValue,
                CharValue       = char.MinValue,
                DoublePrimitive = double.MinValue,
                FloatPrimitive  = float.MinValue,
                IntPrimitive    = int.MinValue,
                LongPrimitive   = long.MinValue,
                ShortPrimitive  = short.MinValue,
                StringPrimitive = "some string",
                TimeSpanValue   = TimeSpan.MinValue,
            };

            BasicTypes rightObject = leftObject.Clone();

            ObjectGraphFactory  factory  = new PublicPropertyObjectGraphFactory();
            ObjectGraphComparer comparer = new ObjectGraphComparer();
            var  left  = factory.CreateObjectGraph(leftObject);
            var  right = factory.CreateObjectGraph(rightObject);
            bool match = comparer.Compare(left, right);

            Assert.True(match, "Basic types did not match");
        }
        public BasicTypes Clone()
        {
            BasicTypes clone = new BasicTypes()
            {
                BoolPrimitive   = this.BoolPrimitive,
                BytePrimitive   = this.BytePrimitive,
                CharValue       = this.CharValue,
                DoublePrimitive = this.DoublePrimitive,
                FloatPrimitive  = this.FloatPrimitive,
                IntPrimitive    = this.IntPrimitive,
                LongPrimitive   = this.LongPrimitive,
                ShortPrimitive  = this.ShortPrimitive,
                StringPrimitive = this.StringPrimitive,
                TimeSpanValue   = this.TimeSpanValue,
            };

            return(clone);
        }
        public void CompareBasicTypesMinValues()
        {
            BasicTypes leftObject = new BasicTypes()
            {
                BoolPrimitive   = false,
                BytePrimitive   = byte.MinValue,
                CharValue       = char.MinValue,
                DoublePrimitive = double.MinValue,
                FloatPrimitive  = float.MinValue,
                IntPrimitive    = int.MinValue,
                LongPrimitive   = long.MinValue,
                ShortPrimitive  = short.MinValue,
                StringPrimitive = "some string",
                TimeSpanValue   = TimeSpan.MinValue,
            };

            BasicTypes rightObject = new BasicTypes()
            {
                BoolPrimitive   = true,
                BytePrimitive   = byte.MaxValue,
                CharValue       = char.MaxValue,
                DoublePrimitive = double.MaxValue,
                FloatPrimitive  = float.MaxValue,
                IntPrimitive    = int.MaxValue,
                LongPrimitive   = long.MaxValue,
                ShortPrimitive  = short.MaxValue,
                StringPrimitive = string.Empty,
                TimeSpanValue   = TimeSpan.MaxValue,
            };

            ObjectGraphFactory  factory  = new PublicPropertyObjectGraphFactory();
            ObjectGraphComparer comparer = new ObjectGraphComparer();
            var  left  = factory.CreateObjectGraph(leftObject);
            var  right = factory.CreateObjectGraph(rightObject);
            bool match = comparer.Compare(left, right);

            Assert.False(match, "Basic types matched when they should not");
        }
Пример #4
0
        public void CompareBasicTypesMaxValues()
        {
            BasicTypes leftObject = new BasicTypes()
            {
                BoolPrimitive   = true,
                BytePrimitive   = byte.MaxValue,
                CharValue       = char.MaxValue,
                DoublePrimitive = double.MaxValue,
                FloatPrimitive  = float.MaxValue,
                IntPrimitive    = int.MaxValue,
                LongPrimitive   = long.MaxValue,
                ShortPrimitive  = short.MaxValue,
                StringPrimitive = string.Empty,
                TimeSpanValue   = TimeSpan.MaxValue,
            };

            BasicTypes rightObject = leftObject.Clone();

            ObjectGraphFactory factory  = new PublicPropertyObjectGraphFactory();
            ObjectComparer     comparer = new ObjectComparer(factory);
            bool match = comparer.Compare(leftObject, rightObject);

            Assert.True(match, "Basic types did not match");
        }