Exemplo n.º 1
0
        public static void CheckLoggedValues(
            ITestLoggerFactory loggerFactory,
            LogLevel minLogLevel,
            IReadOnlyCollection <string> expectedLoggedValues)
        {
            var infoOrHigherEntries =
                loggerFactory.Sink.LogEntries.Where(x => x.LogLevel >= minLogLevel);

            var assertions = expectedLoggedValues.Select(
                expected =>
            {
                return(new Action <LogEntry>(
                           entry =>
                {
                    var actual = SpaceCompressor.CompressSpaces(entry.Message !);
                    var expected2 = SpaceCompressor.CompressSpaces(expected);

                    actual.Should().Be(expected2);
                }
                           ));
            }
                );

            if (expectedLoggedValues.IsNullOrEmpty())
            {
                infoOrHigherEntries.Should().BeEmpty("Log values should be empty");
            }
            else
            {
                infoOrHigherEntries.Should()
                .SatisfyRespectively(assertions, "Log value should match expected");
            }
        }
Exemplo n.º 2
0
            /// <inheritdoc />
            public async Task RunAsync(ITestOutputHelper testOutputHelper)
            {
                var realSCL = SpaceCompressor.CompressNewLines(Step.Serialize().TrimEnd());

                testOutputHelper.WriteLine(realSCL);
                var trueExpected = SpaceCompressor.CompressNewLines(ExpectedSCL.Trim());

                realSCL.Should().Be(trueExpected);

                await Task.CompletedTask;
            }