예제 #1
0
        public void DoSomething_ShouldThrowArgumentNullException_WhenSomeDataIsNull()
        {
            // arrange
            var assertionExample = new AssertionExample();

            // act
            Action action = () => assertionExample.DoSomething(null);

            // assert
            action.ShouldThrowExactly <ArgumentNullException>();
        }
예제 #2
0
        public void DoSomething_ShouldThrowArgumentException_WhenSomeStringIsEmpty()
        {
            // arrange
            var assertionExample = new AssertionExample();
            var someData         = new SomeData {
                SomeString = string.Empty
            };

            // act
            Action action = () => assertionExample.DoSomething(someData);

            // assert
            action.ShouldThrowExactly <ArgumentException>();

            // act
            // assert
            try { action(); }
            catch (ArgumentException ex) { ex.Message.Should().Contain("someData.SomeString"); }
        }