Exemple #1
0
        public void HashSetOfWithCollisionsWhenNotEqual(ReferenceHandling referenceHandling)
        {
            var e1 = new HashCollisionType();
            var x  = new HashSet <HashCollisionType> {
                e1, new HashCollisionType {
                    Value = 1
                }
            };
            var y = new HashSet <HashCollisionType> {
                e1, new HashCollisionType {
                    Value = 2
                }
            };
            var expected = "HashSet<HashCollisionType> [Gu.State.Tests.DiffTests.DiffTypes+HashCollisionType] x: Gu.State.Tests.DiffTests.DiffTypes+HashCollisionType y: missing item [Gu.State.Tests.DiffTests.DiffTypes+HashCollisionType] x: missing item y: Gu.State.Tests.DiffTests.DiffTypes+HashCollisionType";

            var result = this.DiffMethod(x, y, referenceHandling);

            Assert.AreEqual(false, result.IsEmpty);
            var actual = result.ToString(string.Empty, " ");

            StringAssert.AreEqualIgnoringCase(expected, actual);

            result = this.DiffMethod(y, x, referenceHandling);
            Assert.AreEqual(false, result.IsEmpty);
            actual = result.ToString(string.Empty, " ");
            StringAssert.AreEqualIgnoringCase(expected, actual);
        }
Exemple #2
0
        public void WithCollisionsWhenEqual(ReferenceHandling referenceHandling)
        {
            var e1 = new HashCollisionType();
            var e2 = new HashCollisionType();
            var x  = new HashSet <HashCollisionType> {
                e1, e2
            };
            var y = new HashSet <HashCollisionType> {
                e2, e1
            };
            var result = this.EqualByMethod(x, y, referenceHandling);

            Assert.AreEqual(true, result);

            result = this.EqualByMethod(y, x, referenceHandling);
            Assert.AreEqual(true, result);
        }
Exemple #3
0
        public void HashSetOfWithCollisionsWhenEqual(ReferenceHandling referenceHandling)
        {
            var e1 = new HashCollisionType();
            var e2 = new HashCollisionType();
            var x  = new HashSet <HashCollisionType> {
                e1, e2
            };
            var y = new HashSet <HashCollisionType> {
                e2, e1
            };
            var result = this.DiffMethod(x, y, referenceHandling);

            Assert.AreEqual(true, result.IsEmpty);
            Assert.AreEqual("Empty", result.ToString());

            result = this.DiffMethod(y, x, referenceHandling);
            Assert.AreEqual(true, result.IsEmpty);
            Assert.AreEqual("Empty", result.ToString());
        }
Exemple #4
0
        public void WithCollisionsWhenNotEqual(ReferenceHandling referenceHandling)
        {
            var e1 = new HashCollisionType();
            var x  = new HashSet <HashCollisionType> {
                e1, new HashCollisionType {
                    Value = 1
                }
            };
            var y = new HashSet <HashCollisionType> {
                e1, new HashCollisionType {
                    Value = 2
                }
            };
            var result = this.EqualByMethod(x, y, referenceHandling);

            Assert.AreEqual(false, result);

            result = this.EqualByMethod(y, x, referenceHandling);
            Assert.AreEqual(false, result);
        }
Exemple #5
0
        public void WithCollisionsWhenEqual()
        {
            var k1 = new HashCollisionType();
            var k2 = new HashCollisionType();
            var x  = new Dictionary <HashCollisionType, string> {
                { k1, "1" }, { k2, "2" }
            };
            var y = new Dictionary <HashCollisionType, string> {
                { k1, "1" }, { k2, "2" }
            };

            Assert.AreEqual(2, x.Count);
            var result = this.EqualByMethod(x, y, ReferenceHandling.Structural);

            Assert.AreEqual(true, result);

            y = new Dictionary <HashCollisionType, string> {
                { k2, "2" }, { k1, "1" }
            };
            result = this.EqualByMethod(x, y, ReferenceHandling.Structural);
            Assert.AreEqual(true, result);
        }
Exemple #6
0
        public void HashSetOfWithCollisionsWhenNotEqualReference()
        {
            var e1 = new HashCollisionType();
            var x  = new HashSet <HashCollisionType> {
                e1, new HashCollisionType()
            };
            var y = new HashSet <HashCollisionType> {
                e1, new HashCollisionType()
            };
            var expected = "HashSet<HashCollisionType> [Gu.State.Tests.DiffTests.DiffTypes+HashCollisionType] x: Gu.State.Tests.DiffTests.DiffTypes+HashCollisionType y: missing item [Gu.State.Tests.DiffTests.DiffTypes+HashCollisionType] x: missing item y: Gu.State.Tests.DiffTests.DiffTypes+HashCollisionType";

            var result = this.DiffMethod(x, y, ReferenceHandling.References);

            Assert.AreEqual(false, result.IsEmpty);
            var actual = result.ToString("", " ");

            Assert.AreEqual(expected, actual);

            result = this.DiffMethod(y, x, ReferenceHandling.References);
            Assert.AreEqual(false, result.IsEmpty);
            actual = result.ToString("", " ");
            Assert.AreEqual(expected, actual);
        }