public void SetUp()
        {
            _setting1 = new TypicalSetting
            {
                Name    = "Johan Larsson",
                Dummies = Enumerable.Range(0, 1)
                          .Select(x => new DummySerializable(x))
                          .ToList(),
                Value1 = 1.2,
                Value2 = 2,
                Value3 = 3,
                Value4 = 4,
                Value5 = 5
            };

            _setting2 = new TypicalSetting
            {
                Name    = "Johan Larsson",
                Dummies = Enumerable.Range(0, 1)
                          .Select(x => new DummySerializable(x))
                          .ToList(),
                Value1 = 1.2,
                Value2 = 2,
                Value3 = 3,
                Value4 = 4,
                Value5 = 5
            };
        }
Example #2
0
        public void WhenNotEqual()
        {
            var setting1 = new TypicalSetting
            {
                Name    = "Johan Larsson",
                Dummies = Enumerable.Range(0, 1)
                          .Select(x => new DummySerializable(x))
                          .ToList(),
                Value1 = 1.2,
                Value2 = 2,
                Value3 = 3,
                Value4 = 4,
                Value5 = 5,
            };

            var setting2 = new TypicalSetting
            {
                Name    = "Johan Larsson",
                Dummies = Enumerable.Range(0, 1)
                          .Select(x => new DummySerializable(x))
                          .ToList(),
                Value1 = 2.3,
                Value2 = 2,
                Value3 = 3,
                Value4 = 4,
                Value5 = 5,
            };

            var comparer = XmlEqualsComparer <TypicalSetting> .Default;

            Assert.AreNotEqual(setting1.Value1, setting2.Value1);
            Assert.IsFalse(comparer.Equals(setting1, setting2));

            Assert.AreNotEqual(comparer.GetHashCode(setting1), comparer.GetHashCode(setting2));
        }
Example #3
0
        public void GetHashCode(ComparerData data)
        {
            var setting1 = new TypicalSetting
            {
                Name    = "Johan Larsson",
                Dummies = Enumerable.Range(0, 1).Select(x => new DummySerializable(x)).ToList(),
                Value1  = 1.2,
                Value2  = 2,
                Value3  = 3,
                Value4  = 4,
                Value5  = 5,
            };

            var comparer = XmlEqualsComparer <TypicalSetting> .Default;
            var warmup   = comparer.GetHashCode(setting1);
            var sw       = Stopwatch.StartNew();

            for (var i = 0; i < data.Times; i++)
            {
                var result = comparer.GetHashCode(setting1);
            }

            sw.Stop();
            Console.WriteLine(
                "{0}.GetHashCode(_setting1) {1} times took: {2} ms total ({3} ms each)",
                data.ComparerName,
                data.Times,
                sw.ElapsedMilliseconds,
                sw.Elapsed.TotalMilliseconds / data.Times);
        }