コード例 #1
0
        public void NotNull_ObjectNull_DoesThrowException()
        {
            // Arrange
            object reference     = null;
            object returnedValue = null;

            PostConditionViolatedException exception = null;

            // Act
            try
            {
                returnedValue = Postcondition.NotNull(reference);
            }
            catch (PostConditionViolatedException e)
            {
                exception = e;
            }

            // Assert
            Check.That(exception).IsNotNull();
            Check.That(returnedValue).IsNull();
        }
コード例 #2
0
        public void Is_ConditionNotFulfilledWithMessage_DoesThrowException()
        {
            // Arrange
            bool exceptionThrown = false;
            PostConditionViolatedException exception = null;

            // Act
            try
            {
                Postcondition.Is(false, "Test message");
            }
            catch (Exception ex)
            {
                exceptionThrown = true;
                exception       = ex as PostConditionViolatedException;
            }

            // Assert
            Check.That(exceptionThrown).IsTrue();
            Check.That(exception).IsInstanceOf <PostConditionViolatedException>();
            Check.That(exception.Message).Equals("Test message");
        }