Beispiel #1
0
        public void StatusIsComparedBasedOnId()
        {
            // Arrange
            var comp = new StatusComparer();
            var a    = new Status
            {
                ID = 123
            };
            var b = new Status
            {
                ID = 123
            };
            var c = new Status
            {
                ID = 111
            };

            // Act
            var ab = comp.Equals(a, b);
            var ba = comp.Equals(b, a);
            var ac = comp.Equals(a, c);

            // Assert
            Assert.IsTrue(ab);
            Assert.IsTrue(ba);
            Assert.IsFalse(ac);
        }
Beispiel #2
0
        public void HashCodeForNullThrowsException()
        {
            // Arrange
            var comp = new StatusComparer();

            // Act
            var ex = ExceptionAssert.Catch <ArgumentNullException>(() => comp.GetHashCode(null));

            // Assert
            Assert.IsNotNull(ex);
        }
Beispiel #3
0
        public void HashCodeForNullThrowsException()
        {
            // Arrange
            var comp = new StatusComparer();

            // Act
            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            var ex = ExceptionAssert.Catch <ArgumentNullException>(() => comp.GetHashCode(null));

            // Assert
            Assert.IsNotNull(ex);
        }
Beispiel #4
0
        public void HashCodeForObjectIsCalculatedCorrectly()
        {
            // Arrange
            var comp   = new StatusComparer();
            var entity = new Status
            {
                ID = 123
            };

            // Act
            var hash = comp.GetHashCode(entity);

            // Assert
            Assert.AreEqual(entity.ID.GetHashCode(), hash);
        }