示例#1
0
    public void StringEndsWithCaseInsensitive()
    {
        string expectedValue = "YX";
        string actualValue   = "xxx";

        // MSTest does not support this case.

        // NUnit
        Assert.That(actualValue, Does.EndWith(expectedValue).IgnoreCase, () => "Some context");
        // Some context
        //  Expected: String ending with "YX", ignoring case
        //  But was: "xxx"

        // XUnit
        XUnitAssert.EndsWith(expectedValue, actualValue, StringComparison.CurrentCultureIgnoreCase);
        // Assert.EndsWith() Failure
        // Expected: YX
        // Actual: ***xx

        // Fluent
        actualValue.Should().EndWithEquivalent(expectedValue, "SOME REASONS");
        // Expected actualValue that ends with equivalent of "YX" because SOME REASONS, but found "xxx".

        // Shouldly
        actualValue.ShouldEndWith(expectedValue, "Some context");
        // actualValue
        //   should end with
        // "YX"
        //   but was
        // "xxx"
        //
        // Additional Info:
        //  Some context
    }
示例#2
0
        public async Task Init()
        {
            var chat = this.fixture.GrainFactory.GetGrain <IChatGrain>($"Chatroom-{Guid.NewGuid()}");

            var content = (await chat.GetChat()).ToString();

            var expectedprefix = "<!--This chat room was created by TestGrains.ChatGrain-->\r\n<root>\r\n  <created>";
            var expectedsuffix = "</created>\r\n  <posts />\r\n</root>";

            Assert.StartsWith(expectedprefix, content);
            Assert.EndsWith(expectedsuffix, content);
        }
示例#3
0
    public void StringEndsWith()
    {
        string expectedValue = "XX";
        string actualValue   = "xxx";

        // MSTest
        MSTestStringAssert.EndsWith(actualValue, expectedValue, "Some context");
        // StringAssert.EndsWith failed. String 'xxx' does not end with string 'XX'. Some context

        // NUnit
        Assert.That(actualValue, Does.EndWith(expectedValue), () => "Some context");
        // Some context
        //  Expected: String ending with "XX"
        //  But was: "xxx"

        // XUnit
        XUnitAssert.EndsWith(expectedValue, actualValue);
        // Assert.EndsWith() Failure
        // Expected: XX
        // Actual: ***xx

        // Fluent
        actualValue.Should().EndWith(expectedValue, "SOME REASONS");
        // Expected actualValue "xxx" to end with "XX" because SOME REASONS.

        // Shouldly
        actualValue.ShouldEndWith(expectedValue, "Some context", Case.Sensitive);
        // actualValue
        //   should end with
        // "XX"
        //   but was
        // "xxx"
        //
        // Additional Info:
        //  Some context
    }