예제 #1
0
        public void CanUseComparer()
        {
            List <int> list = new List <int>();

            list.Add(42);

            Assert.DoesNotContain(42, list, new MyComparer());
        }
예제 #2
0
        public void NullsAllowedInContainer()
        {
            List <object> list = new List <object> {
                null, 16, "Hi there"
            };

            Assert.DoesNotContain(42, list);
        }
예제 #3
0
        public void CanSearchForNullInContainer()
        {
            List <object> list = new List <object> {
                16, "Hi there"
            };

            Assert.DoesNotContain(null, list);
        }
예제 #4
0
        public void ItemInContainer()
        {
            List <int> list = new List <int> {
                42
            };

            DoesNotContainException ex =
                Assert.Throws <DoesNotContainException>(() => Assert.DoesNotContain(42, list));

            Assert.Equal("Assert.DoesNotContain() failure: Found: 42", ex.Message);
        }
예제 #5
0
        public void SameFailsWith()
        {
            string actual   = "Abc";
            string expected = "a".ToUpperInvariant() + "bc";

            try
            {
                Assert.Same(expected, actual);
            }
            catch (Exception ex)
            {
                AssertException aex = Assert.IsAssignableFrom <AssertException>(ex);
                Assert.Equal("Assert.Same() Failure", aex.UserMessage);
                Assert.DoesNotContain("Position:", aex.Message);
            }
        }
예제 #6
0
            public void StackTraceForThrowsIsOriginalThrowNotAssertThrows()
            {
                var wasFilterStackTraceAssemblyPrefix = AssertException.FilterStackTraceAssemblyPrefix;

                AssertException.FilterStackTraceAssemblyPrefix = "Should.Core";
                Assert.ThrowsDelegate throwsDelegate = ThrowingMethod;
                try
                {
                    Assert.Throws <InvalidCastException>(throwsDelegate);
                }
                catch (AssertActualExpectedException exception)
                {
                    Assert.Contains(GetMethodFullName(throwsDelegate), exception.StackTrace);
                    Assert.DoesNotContain("Should.Core", exception.StackTrace);
                }
                finally
                {
                    AssertException.FilterStackTraceAssemblyPrefix = wasFilterStackTraceAssemblyPrefix;
                }
            }
예제 #7
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;
                }
            }
예제 #8
0
 public void SubstringFound()
 {
     Assert.Throws <DoesNotContainException>(() => Assert.DoesNotContain("world", "Hello, world!"));
 }
예제 #9
0
 public void SubstringDoesNotContainIsCaseSensitiveByDefault()
 {
     Assert.DoesNotContain("WORLD", "Hello, world!");
 }
예제 #10
0
        public void ItemNotInContainer()
        {
            List <int> list = new List <int>();

            Assert.DoesNotContain(42, list);
        }
예제 #11
0
 public void CanSearchForSubstringsCaseInsensitive()
 {
     Assert.Throws <DoesNotContainException>(
         () => Assert.DoesNotContain("WORLD", "Hello, world!", StringComparison.OrdinalIgnoreCase));
 }
예제 #12
0
 public void CanSearchForSubstrings()
 {
     Assert.DoesNotContain("hey", "Hello, world!");
 }