コード例 #1
0
            public void ShouldThrowCodeContractViolationException()
            {
                //Arrange
                var notifier = new ExceptionNotifier();

                //Act and assert
                Assert.Throws<CodeContractViolationException>(() => notifier.Notify(TestDataFactory.CreateViolationData()));
            }
コード例 #2
0
            public void ShouldThrowCodeContractViolationException()
            {
                //Arrange
                var notifier = new ExceptionNotifier();


                //Act and assert
                Assert.Throws <CodeContractViolationException>(() => notifier.Notify(TestDataFactory.CreateViolationData()));
            }
コード例 #3
0
            public void ThrownExceptionShouldHaveValueFromData()
            {
                //Arrange
                const int expectedValue = 123456;
                var notifier = new ExceptionNotifier();

                //Act
                var exception = Assert.Throws<CodeContractViolationException>(() => notifier.Notify(TestDataFactory.CreateViolationData(expectedValue)));

                //Assert
                Assert.Equal(expectedValue, exception.Value);
            }
コード例 #4
0
            public void ThrownExceptionShouldHaveNameFromData()
            {
                //Arrange
                const string expectedName = "VariableName";
                var notifier = new ExceptionNotifier();

                //Act
                var exception = Assert.Throws<CodeContractViolationException>(() => notifier.Notify(TestDataFactory.CreateViolationData(name: expectedName)));

                //Assert
                Assert.Equal(expectedName, exception.Name);
            }
コード例 #5
0
            public void ThrownExceptionShouldHaveMessageFromData()
            {
                //Arrange
                const string expectedErrorMessage = "ExpectedErrorMessage";
                var notifier = new ExceptionNotifier();

                //Act
                var exception = Assert.Throws<CodeContractViolationException>(() => notifier.Notify(TestDataFactory.CreateViolationData(errorMessage: expectedErrorMessage)));

                //Assert
                Assert.Equal(expectedErrorMessage, exception.Message);
            }
コード例 #6
0
            public void ThrownExceptionShouldHaveNameFromData()
            {
                //Arrange
                const string expectedName = "VariableName";
                var          notifier     = new ExceptionNotifier();


                //Act
                var exception = Assert.Throws <CodeContractViolationException>(() => notifier.Notify(TestDataFactory.CreateViolationData(name: expectedName)));


                //Assert
                Assert.Equal(expectedName, exception.Name);
            }
コード例 #7
0
            public void ThrownExceptionShouldHaveValueFromData()
            {
                //Arrange
                const int expectedValue = 123456;
                var       notifier      = new ExceptionNotifier();


                //Act
                var exception = Assert.Throws <CodeContractViolationException>(() => notifier.Notify(TestDataFactory.CreateViolationData(expectedValue)));


                //Assert
                Assert.Equal(expectedValue, exception.Value);
            }
コード例 #8
0
            public void ThrownExceptionShouldHaveMessageFromData()
            {
                //Arrange
                const string expectedErrorMessage = "ExpectedErrorMessage";
                var          notifier             = new ExceptionNotifier();


                //Act
                var exception = Assert.Throws <CodeContractViolationException>(() => notifier.Notify(TestDataFactory.CreateViolationData(errorMessage: expectedErrorMessage)));


                //Assert
                Assert.Equal(expectedErrorMessage, exception.Message);
            }