public void GotExpectedException()
        {
            var accessor = new StubAccessor();

            var ex = Assert.Throws <InvalidOperationException>(() => accessor.FailingProperty);

            Assert.NotNull(ex);
        }
Exemple #2
0
            public void NoException()
            {
                StubAccessor accessor = new StubAccessor();

                Exception ex = Record.Exception(() => accessor.SuccessfulProperty);

                Assert.Null(ex);
            }
        public void GotDerivedException()
        {
            var accessor = new StubAccessor();

            var ex = Assert.ThrowsAny <Exception>(() => accessor.FailingProperty);

            Assert.NotNull(ex);
        }
Exemple #4
0
            public void NoException()
            {
                StubAccessor accessor = new StubAccessor();

                Exception ex = Record.Exception(() => accessor.SuccessfulProperty);

                Assert.Null(ex);
            }
Exemple #5
0
            public void Exception()
            {
                StubAccessor accessor = new StubAccessor();

                Exception ex = Record.Exception(() => accessor.FailingProperty);

                Assert.NotNull(ex);
                Assert.IsType <InvalidOperationException>(ex);
            }
Exemple #6
0
            public void Exception()
            {
                StubAccessor accessor = new StubAccessor();

                Exception ex = Record.Exception(() => accessor.FailingProperty);

                Assert.NotNull(ex);
                Assert.IsType<InvalidOperationException>(ex);
            }
Exemple #7
0
            public void GotExpectedException()
            {
                StubAccessor accessor = new StubAccessor();

                Exception ex =
                    Assert.Throws(typeof(InvalidOperationException), () => accessor.FailingProperty);

                Assert.NotNull(ex);
                Assert.IsType <InvalidOperationException>(ex);
            }
Exemple #8
0
            public void ExpectExceptionButCodeDoesNotThrow()
            {
                StubAccessor accessor = new StubAccessor();

                try
                {
                    Assert.Throws<ArgumentException>(() => accessor.SuccessfulProperty);
                }
                catch (AssertActualExpectedException exception)
                {
                    Assert.Equal("(No exception was thrown)", exception.Actual);
                }
            }
Exemple #9
0
            public void ExpectExceptionButCodeThrowsDerivedException()
            {
                StubAccessor accessor = new StubAccessor();

                try
                {
                    Assert.Throws(typeof(Exception), () => accessor.FailingProperty);
                }
                catch (AssertException exception)
                {
                    Assert.Equal("Assert.Throws() Failure", exception.UserMessage);
                }
            }
Exemple #10
0
        public static void ExpectExceptionButCodeThrowsDerivedException()
        {
            var accessor = new StubAccessor();

            try
            {
                Assert.Throws <Exception>(() => accessor.FailingProperty);
            }
            catch (XunitException exception)
            {
                Assert.Equal("Assert.Throws() Failure", exception.UserMessage);
            }
        }
Exemple #11
0
            public void ExpectExceptionButCodeDoesNotThrow()
            {
                StubAccessor accessor = new StubAccessor();

                try
                {
                    Assert.Throws <ArgumentException>(() => accessor.SuccessfulProperty);
                }
                catch (AssertActualExpectedException exception)
                {
                    Assert.Equal("(No exception was thrown)", exception.Actual);
                }
            }
        public void StackTraceForThrowsIsOriginalThrowNotAssertThrows()
        {
            var accessor = new StubAccessor();

            try
            {
                Assert.Throws <InvalidCastException>(() => accessor.FailingProperty);
            }
            catch (AssertActualExpectedException exception)
            {
                Assert.Contains("StubAccessor.get_FailingProperty", exception.StackTrace);
                Assert.DoesNotContain("Xunit.Assert", exception.StackTrace);
            }
        }
Exemple #13
0
            public void StackTraceForThrowsIsOriginalThrowNotAssertThrows()
            {
                var wasFilterStackTraceAssemblyPrefix = AssertException.FilterStackTraceAssemblyPrefix;

                AssertException.FilterStackTraceAssemblyPrefix = "Should.Core";
                StubAccessor accessor = new StubAccessor();

                Assert.ThrowsDelegateWithReturn throwsDelegateWithReturn = () => accessor.FailingProperty;
                try
                {
                    Assert.Throws <InvalidCastException>(throwsDelegateWithReturn);
                }
                catch (AssertActualExpectedException exception)
                {
                    Assert.Contains(GetMethodFullName(throwsDelegateWithReturn), exception.StackTrace);
                    Assert.DoesNotContain("Should.Core", exception.StackTrace);
                }
                finally
                {
                    AssertException.FilterStackTraceAssemblyPrefix = wasFilterStackTraceAssemblyPrefix;
                }
            }
Exemple #14
0
            public void GotExpectedException()
            {
                StubAccessor accessor = new StubAccessor();

                Exception ex =
                    Assert.Throws(typeof(InvalidOperationException), () => accessor.FailingProperty);

                Assert.NotNull(ex);
                Assert.IsType<InvalidOperationException>(ex);
            }
Exemple #15
0
            public void StackTraceForThrowsIsOriginalThrowNotAssertThrows()
            {
                StubAccessor accessor = new StubAccessor();

                try
                {
                    Assert.Throws<InvalidCastException>(() => accessor.FailingProperty);
                }
                catch (AssertActualExpectedException exception)
                {
                    Assert.Contains("StubAccessor.get_FailingProperty", exception.StackTrace);
                    Assert.DoesNotContain("Xunit.Assert", exception.StackTrace);
                }
            }
        public void GotDerivedException()
        {
            var accessor = new StubAccessor();

            var ex = Assert.ThrowsAny<Exception>(() => accessor.FailingProperty);

            Assert.NotNull(ex);
        }
        public void GotExpectedException()
        {
            var accessor = new StubAccessor();

            var ex = Assert.ThrowsAny<InvalidOperationException>(() => accessor.FailingProperty);

            Assert.NotNull(ex);
        }
Exemple #18
0
        public static void ExpectExceptionButCodeThrowsDerivedException()
        {
            var accessor = new StubAccessor();

            try
            {
                Assert.Throws(typeof(Exception), () => accessor.FailingProperty);
            }
            catch (XunitException exception)
            {
                Assert.Equal("Assert.Throws() Failure", exception.UserMessage);
            }
        }
Exemple #19
0
            public void ExpectExceptionButCodeThrowsDerivedException()
            {
                StubAccessor accessor = new StubAccessor();

                try
                {
                    Assert.Throws<Exception>(() => accessor.FailingProperty);
                }
                catch (AssertException exception)
                {
                    Assert.Equal("Assert.Throws() Failure", exception.UserMessage);
                }
            }
Exemple #20
0
 public void StackTraceForThrowsIsOriginalThrowNotAssertThrows()
 {
     var wasFilterStackTraceAssemblyPrefix = AssertException.FilterStackTraceAssemblyPrefix;
     AssertException.FilterStackTraceAssemblyPrefix = "Should.Core";
     StubAccessor accessor = new StubAccessor();
     Assert.ThrowsDelegateWithReturn throwsDelegateWithReturn = () => accessor.FailingProperty;
     try
     {
         Assert.Throws<InvalidCastException>(throwsDelegateWithReturn);
     }
     catch (AssertActualExpectedException exception)
     {
         Assert.Contains(GetMethodFullName(throwsDelegateWithReturn), exception.StackTrace);
         Assert.DoesNotContain("Should.Core", exception.StackTrace);
     }
     finally
     {
         AssertException.FilterStackTraceAssemblyPrefix = wasFilterStackTraceAssemblyPrefix;
     }
 }