示例#1
0
        public void TestTrueMessage()
        {
            var verifier  = new XUnitVerifier();
            var exception = Assert.ThrowsAny <TrueException>(() => verifier.True(false));

            Assert.Equal($"Assert.True() Failure{Environment.NewLine}Expected: True{Environment.NewLine}Actual:   False", exception.Message);
        }
示例#2
0
        public void TestTrueMessageWithContext()
        {
            var verifier  = new XUnitVerifier().PushContext("Known Context");
            var exception = Assert.ThrowsAny <TrueException>(() => verifier.True(false));

            Assert.Equal($"Context: Known Context{Environment.NewLine}{Environment.NewLine}Expected: True{Environment.NewLine}Actual:   False", exception.Message);
        }
示例#3
0
        public void TestLanguageIsSupportedMessageWithContext()
        {
            var verifier  = new XUnitVerifier().PushContext("Known Context");
            var exception = Assert.ThrowsAny <FalseException>(() => verifier.LanguageIsSupported("NonLanguage"));

            Assert.Equal($"Context: Known Context{Environment.NewLine}Unsupported Language: 'NonLanguage'{Environment.NewLine}Expected: False{Environment.NewLine}Actual:   True", exception.Message);
        }
示例#4
0
        public void TestFailCustomMessage()
        {
            var verifier  = new XUnitVerifier();
            var exception = Assert.ThrowsAny <TrueException>(() => verifier.Fail("Custom message"));

            Assert.Equal($"Custom message{Environment.NewLine}Expected: True{Environment.NewLine}Actual:   False", exception.Message);
        }
示例#5
0
        public void TestFalseCustomMessageWithContext()
        {
            var verifier  = new XUnitVerifier().PushContext("Known Context");
            var exception = Assert.ThrowsAny <FalseException>(() => verifier.False(true, "Custom message"));

            Assert.Equal($"Context: Known Context{Environment.NewLine}Custom message{Environment.NewLine}Expected: False{Environment.NewLine}Actual:   True", exception.Message);
        }
示例#6
0
        public void TestNotEmptyMessageWithContext()
        {
            var actual    = new int[0];
            var verifier  = new XUnitVerifier().PushContext("Known Context");
            var exception = Assert.ThrowsAny <NotEmptyException>(() => verifier.NotEmpty("someCollectionName", actual));

            Assert.Equal($"Context: Known Context{Environment.NewLine}'someCollectionName' is empty{Environment.NewLine}Assert.NotEmpty() Failure", exception.Message);
        }
示例#7
0
        public void TestEmptyMessage()
        {
            var actual    = new int[1];
            var verifier  = new XUnitVerifier();
            var exception = Assert.ThrowsAny <EmptyException>(() => verifier.Empty("someCollectionName", actual));

            Assert.Same(actual, exception.Collection);
            Assert.Equal($"'someCollectionName' is not empty{Environment.NewLine}Assert.Empty() Failure{Environment.NewLine}Collection: [0]", exception.Message);
        }
示例#8
0
        public void TestEqualCustomMessageWithContext()
        {
            var expected  = 0;
            var actual    = 1;
            var verifier  = new XUnitVerifier().PushContext("Known Context");
            var exception = Assert.ThrowsAny <EqualException>(() => verifier.Equal(expected, actual, "Custom message"));

            Assert.Equal(expected.ToString(), exception.Expected);
            Assert.Equal(actual.ToString(), exception.Actual);
            Assert.Equal($"Context: Known Context{Environment.NewLine}Custom message{Environment.NewLine}Assert.Equal() Failure{Environment.NewLine}Expected: 0{Environment.NewLine}Actual:   1", exception.Message);
        }
示例#9
0
        public void TestEqualMessage()
        {
            var expected  = 0;
            var actual    = 1;
            var verifier  = new XUnitVerifier();
            var exception = Assert.ThrowsAny <EqualException>(() => verifier.Equal(expected, actual));

            Assert.Equal(expected.ToString(), exception.Expected);
            Assert.Equal(actual.ToString(), exception.Actual);
            Assert.Equal($"Assert.Equal() Failure{Environment.NewLine}Expected: 0{Environment.NewLine}Actual:   1", exception.Message);
        }
示例#10
0
        public void TestSequenceEqualCustomMessageWithContext()
        {
            var expected  = new int[] { 0 };
            var actual    = new int[] { 1 };
            var verifier  = new XUnitVerifier().PushContext("Known Context");
            var exception = Assert.ThrowsAny <EqualException>(() => verifier.SequenceEqual(expected, actual, message: "Custom message"));

            Assert.Equal("Int32[] [0]", exception.Expected);
            Assert.Equal("Int32[] [1]", exception.Actual);
            Assert.Equal($"Context: Known Context{Environment.NewLine}Custom message{Environment.NewLine}Assert.Equal() Failure{Environment.NewLine}Expected: Int32[] [0]{Environment.NewLine}Actual:   Int32[] [1]", exception.Message);
        }
示例#11
0
        public void TestSequenceEqualMessage()
        {
            var expected  = new int[] { 0 };
            var actual    = new int[] { 1 };
            var verifier  = new XUnitVerifier();
            var exception = Assert.ThrowsAny <EqualException>(() => verifier.SequenceEqual(expected, actual));

            Assert.Equal("Int32[] [0]", exception.Expected);
            Assert.Equal("Int32[] [1]", exception.Actual);
            Assert.Equal($"Assert.Equal() Failure{Environment.NewLine}Expected: Int32[] [0]{Environment.NewLine}Actual:   Int32[] [1]", exception.Message);
        }