Exemplo n.º 1
0
        public void ThrowIfNotEqual_WithComparer_ShouldNotThrowException()
        {
            var left = new ItemTest()
            {
                Value = 4
            };
            var right = new ItemTest()
            {
                Value = 4
            };

            Contract.ThrowIfNotEqual(left, right, new ItemTestEqualityComparer());
        }
Exemplo n.º 2
0
        public void ThrowIfEqual_ReferenceComparerWIthMessage_ShouldNotThrowException()
        {
            const string message = "a useful message.";
            var          left    = new ItemTest()
            {
                Value = 4
            };
            var right = new ItemTest()
            {
                Value = 4
            };

            Contract.ThrowIfEqual(left, right, message);
        }
Exemplo n.º 3
0
        public void ThrowIfEqual_WithComparerAndMessage()
        {
            const string message = "a useful message.";
            var          left    = new ItemTest()
            {
                Value = 4
            };
            var right = new ItemTest()
            {
                Value = 4
            };

            var exception = Assert.Throws <ErrorException>(() => Contract.ThrowIfEqual(left, right, new ItemTestEqualityComparer(), null, message));

            Assert.NotNull(exception);
            Assert.True(exception.Message.StartsWith(message));
            Assert.AreEqual(exception.Error, ContractError.ThrowIfEqual.ToError(left.ToSafeString(), right.ToSafeString()));
        }