Пример #1
0
        public static TestConsoleWriter ShouldNotHaveLoggedAnyWarnings([NotNull] this TestConsoleWriter consoleWriter)
        {
            if (consoleWriter == null)
            {
                throw new ArgumentNullException(nameof(consoleWriter));
            }

            if (consoleWriter.Warnings.Any())
            {
                throw new SpecificationException($"Expected no warnings to be logged, but got:\n{consoleWriter.AllEntries}");
            }

            return(consoleWriter);
        }
Пример #2
0
        public static TestConsoleWriter ShouldHaveLoggedOneSingleWarningWithText([NotNull] this TestConsoleWriter consoleWriter, string text)
        {
            if (consoleWriter == null)
            {
                throw new ArgumentNullException(nameof(consoleWriter));
            }

            var matchingMessages = consoleWriter.Warnings.Where(l => l.Contains(text));

            if (matchingMessages.Count() != 1)
            {
                throw new SpecificationException($"Expected a single warning containing text '{text}' but got:\n{consoleWriter.AllEntries}");
            }

            return(consoleWriter);
        }