예제 #1
0
        public async Task Given_server_is_started_when_starting_again_it_should_throw()
        {
            using var server = new MockHttpServer(_fixture.Handler, "http://127.0.0.1");
            await server.StartAsync();

            server.IsStarted.Should().BeTrue();

            // Act
            Func <Task> act = () => server.StartAsync();

            // Assert
            await act.Should().ThrowAsync <InvalidOperationException>();
        }
예제 #2
0
        public async Task When_creating_and_starting_server_with_null_logger_it_should_not_throw()
        {
            ILoggerFactory loggerFactory = null;

            // Act
            // ReSharper disable once ObjectCreationAsStatement
            // ReSharper disable once ExpressionIsAlwaysNull
            Func <MockHttpServer> act = () => new MockHttpServer(new MockHttpHandler(), loggerFactory, "http://127.0.0.1");

            // Assert
            using MockHttpServer server = act.Should().NotThrow().Which;
            Func <Task> act2 = () => server.StartAsync();
            await act2.Should().NotThrowAsync();
        }