Пример #1
0
        public override string GenerateErrorMessage(ShouldlyAssertionContext context)
        {
            const string format = @"
        {0}
    should {1}be within
        {2}
    of
        {3}
    but was 
        {4}";

            var codePart      = context.CodePart;
            var tolerance     = context.Tolerance.Inspect();
            var expectedValue = context.Expected.Inspect();
            var actualValue   = context.Actual.Inspect();
            var negated       = context.ShouldMethod.Contains("Not") ? "not " : string.Empty;

            var message = string.Format(format, codePart, negated, tolerance, expectedValue, actualValue);

            if (DifferenceHighlighterExtensions.CanGenerateDifferencesBetween(context))
            {
                message += string.Format(@"
        difference
    {0}",
                                         DifferenceHighlighterExtensions.HighlightDifferencesBetween(context));
            }

            return(message);
        }
Пример #2
0
        private string CreateActualVsExpectedMessage(ShouldlyAssertionContext context)
        {
            var    codePart = context.CodePart;
            string message  = string.Format(@"
    {0}
        {1}
    {2}
        but was
    {3}",
                                            codePart, context.ShouldMethod.PascalToSpaced(), context.Expected.Inspect(), context.Actual.Inspect());

            if (DifferenceHighlighterExtensions.CanGenerateDifferencesBetween(context))
            {
                message += string.Format(@"
        difference
    {0}",
                                         DifferenceHighlighterExtensions.HighlightDifferencesBetween(context));
            }
            return(message);
        }