public void Build_ProgramMainHasPrivateCtor_ThrowsException()
        {
            var builder = new ConsoleAppBuilder(Array.Empty <string>());

            builder.UseProgramMain <TestProgramMainWithPrivateCtor>();

            // Act
            Action act = () => builder.Build();

            // Assert
            act
            .Should()
            .Throw <InvalidOperationException>();
        }
        public void Build_ProgramMainHasInvalidCtorArgs_ReturnsIntMinValue()
        {
            var builder = new ConsoleAppBuilder(Array.Empty <string>());

            builder.UseProgramMain <TestProgramMainWithInvalidCtorArgs>();

            // Act
            Action act = () => builder.Build();

            // Assert
            act
            .Should()
            .Throw <InvalidOperationException>();
        }
        public void Build_WithStartup_StartupCreatedAndCalled()
        {
            var builder = new ConsoleAppBuilder(Array.Empty <string>());

            builder.UseProgramMain <TestProgramMain>();
            builder.UseStartup <TestStartup>();

            // Act
            var _ = builder.Build();

            // Assert
            TestStartup.ConfigureServicesIsCalled
            .Should()
            .BeTrue();
        }
        public async Task RunAsync_ProgramMainGiven_RunsProgramMain()
        {
            var builder = new ConsoleAppBuilder(Array.Empty <string>());

            builder.UseProgramMain <TestProgramMain>();

            var consoleApp = builder.Build();

            // Act
            var result = await consoleApp.RunAsync();

            // Assert
            result
            .Should()
            .Be(TestProgramMain.ReturnCode);
        }