public void TestBsonTimestampEquals()
        {
            var a = new BsonTimestamp(1);
            var b = new BsonTimestamp(1);
            var c = new BsonTimestamp(2);
            var n = (BsonTimestamp)null;

            Assert.IsTrue(object.Equals(a, b));
            Assert.IsFalse(object.Equals(a, c));
            Assert.IsFalse(object.Equals(a, BsonNull.Value));
            Assert.IsFalse(a.Equals(n));
            Assert.IsFalse(a.Equals(null));

            Assert.IsTrue(a == b);
            Assert.IsFalse(a == c);
            Assert.IsFalse(a == BsonNull.Value);
            Assert.IsFalse(a == null);
            Assert.IsFalse(null == a);
            Assert.IsTrue(n == null);
            Assert.IsTrue(null == n);

            Assert.IsFalse(a != b);
            Assert.IsTrue(a != c);
            Assert.IsTrue(a != BsonNull.Value);
            Assert.IsTrue(a != null);
            Assert.IsTrue(null != a);
            Assert.IsFalse(n != null);
            Assert.IsFalse(null != n);
        }
Beispiel #2
0
        public void Equals_should_return_false_when_other_is_wrong_type()
        {
            var subject = new BsonTimestamp(0);
            var other   = new object();

            var result1 = subject.Equals(other);
            var result2 = subject.Equals((object)other);

            result1.Should().BeFalse();
            result2.Should().BeFalse();
        }
Beispiel #3
0
        public void Equals_should_return_false_when_values_are_not_equal(long value1, long value2)
        {
            var subject = new BsonTimestamp(value1);
            var other   = new BsonTimestamp(value2);

            var result1         = subject.Equals(other);
            var result2         = subject.Equals((object)other);
            var subjectHashCode = subject.GetHashCode();
            var otherHashCode   = other.GetHashCode();

            result1.Should().BeFalse();
            result2.Should().BeFalse();
            otherHashCode.Should().NotBe(subjectHashCode);
        }
Beispiel #4
0
        public void Equals_should_return_true_when_values_are_equal(long value)
        {
            var subject = new BsonTimestamp(value);
            var other   = new BsonTimestamp(value);

            other.Should().NotBeSameAs(subject);

            var result1         = subject.Equals(other);
            var result2         = subject.Equals((object)other);
            var subjectHashCode = subject.GetHashCode();
            var otherHashCode   = other.GetHashCode();

            result1.Should().BeTrue();
            result2.Should().BeTrue();
            otherHashCode.Should().Be(subjectHashCode);
        }
        public void TestBsonTimestampEquals()
        {
            var a = new BsonTimestamp(1);
            var b = new BsonTimestamp(1);
            var c = new BsonTimestamp(2);
            var n = (BsonTimestamp)null;

            Assert.IsTrue(object.Equals(a, b));
            Assert.IsFalse(object.Equals(a, c));
            Assert.IsFalse(object.Equals(a, BsonNull.Value));
            Assert.IsFalse(a.Equals(n));
            Assert.IsFalse(a.Equals(null));

            Assert.IsTrue(a == b);
            Assert.IsFalse(a == c);
            Assert.IsFalse(a == BsonNull.Value);
            Assert.IsFalse(a == null);
            Assert.IsFalse(null == a);
            Assert.IsTrue(n == null);
            Assert.IsTrue(null == n);

            Assert.IsFalse(a != b);
            Assert.IsTrue(a != c);
            Assert.IsTrue(a != BsonNull.Value);
            Assert.IsTrue(a != null);
            Assert.IsTrue(null != a);
            Assert.IsFalse(n != null);
            Assert.IsFalse(null != n);
        }
        public void Equals_should_return_true_when_values_are_equal(long value)
        {
            var subject = new BsonTimestamp(value);
            var other = new BsonTimestamp(value);
            other.Should().NotBeSameAs(subject);

            var result1 = subject.Equals(other);
            var result2 = subject.Equals((object)other);
            var subjectHashCode = subject.GetHashCode();
            var otherHashCode = other.GetHashCode();

            result1.Should().BeTrue();
            result2.Should().BeTrue();
            otherHashCode.Should().Be(subjectHashCode);
        }
        public void Equals_should_return_false_when_values_are_not_equal(long value1, long value2)
        {
            var subject = new BsonTimestamp(value1);
            var other = new BsonTimestamp(value2);

            var result1 = subject.Equals(other);
            var result2 = subject.Equals((object)other);
            var subjectHashCode = subject.GetHashCode();
            var otherHashCode = other.GetHashCode();

            result1.Should().BeFalse();
            result2.Should().BeFalse();
            otherHashCode.Should().NotBe(subjectHashCode);
        }
        public void Equals_should_return_false_when_other_is_wrong_type()
        {
            var subject = new BsonTimestamp(0);
            var other = new object();

            var result1 = subject.Equals(other);
            var result2 = subject.Equals((object)other);

            result1.Should().BeFalse();
            result2.Should().BeFalse();
        }