예제 #1
0
            public async Task SetsLogLevel(string logLevel, int expected)
            {
                // Given
                string[]           args     = new[] { "build", "-l", logLevel };
                TestLoggerProvider provider = new TestLoggerProvider
                {
                    ThrowLogLevel = LogLevel.None
                };
                IBootstrapper bootstrapper = App.Bootstrapper.Create(args);

                bootstrapper.AddCommand <BuildCommand>("build");
                bootstrapper.AddServices(services => services.AddSingleton <ILoggerProvider>(provider));
                bootstrapper.AddPipeline(
                    "Foo",
                    new LogMessage(LogLevel.Trace, "A"),
                    new LogMessage(LogLevel.Debug, "B"),
                    new LogMessage(LogLevel.Information, "C"),
                    new LogMessage(LogLevel.Warning, "D"),
                    new LogMessage(LogLevel.Error, "E"),
                    new LogMessage(LogLevel.Critical, "F"));

                // When
                int exitCode = await bootstrapper.RunAsync();

                // Then
                exitCode.ShouldBe((int)ExitCode.Normal);
                provider.Messages.Count(x => x.CategoryName.StartsWith("Foo")).ShouldBe(expected);
            }
예제 #2
0
            public async Task LogsVersion()
            {
                // Given
                string[]           args         = new[] { "build" };
                TestLoggerProvider provider     = new TestLoggerProvider();
                IBootstrapper      bootstrapper = App.Bootstrapper.Create(args);

                bootstrapper.AddCommand <BuildCommand>("build");
                bootstrapper.AddServices(services => services.AddSingleton <ILoggerProvider>(provider));
                bootstrapper.AddPipeline("Foo");

                // When
                int exitCode = await bootstrapper.RunAsync();

                // Then
                exitCode.ShouldBe((int)ExitCode.Normal);
                provider.Messages.ShouldContain(x => x.FormattedMessage.StartsWith("Statiq version"));
            }
예제 #3
0
            public async Task CatalogsType()
            {
                // Given
                string[]           args         = new[] { "build", "-l", "Debug" };
                TestLoggerProvider provider     = new TestLoggerProvider();
                IBootstrapper      bootstrapper = App.Bootstrapper.Create(args);

                bootstrapper.AddCommand <BuildCommand>("build");
                bootstrapper.AddServices(services => services.AddSingleton <ILoggerProvider>(provider));
                bootstrapper.AddPipeline("Foo");

                // When
                int exitCode = await bootstrapper.RunAsync();

                // Then
                exitCode.ShouldBe((int)ExitCode.Normal);
                bootstrapper.ClassCatalog.GetAssignableFrom <BootstrapperFixture>().Count().ShouldBe(1);
                provider.Messages.ShouldContain(x => x.FormattedMessage.StartsWith("Cataloging types in assembly"));
            }
예제 #4
0
            public async Task NoPipelinesWarning()
            {
                // Given
                string[]           args     = new[] { "build" };
                TestLoggerProvider provider = new TestLoggerProvider
                {
                    ThrowLogLevel = LogLevel.None
                };
                IBootstrapper bootstrapper = App.Bootstrapper.Create(args);

                bootstrapper.AddCommand <BuildCommand>("build");
                bootstrapper.AddServices(services => services.AddSingleton <ILoggerProvider>(provider));

                // When
                int exitCode = await bootstrapper.RunAsync();

                // Then
                exitCode.ShouldBe((int)ExitCode.Normal);
                provider.Messages.ShouldContain(x =>
                                                x.LogLevel == LogLevel.Warning &&
                                                x.FormattedMessage == "No pipelines are configured.");
            }