Exemplo n.º 1
0
        public void When_creating_server_handler_it_should_set_property()
        {
            var handler = new MockHttpHandler();

            // Act
            var server = new MockHttpServer(handler, "http://127.0.0.1");

            // Assert
            server.Handler.Should().Be(handler);
        }
Exemplo n.º 2
0
        public async Task Given_server_is_not_started_when_stopped_it_should_throw()
        {
            using var server = new MockHttpServer(_fixture.Handler, "http://127.0.0.1");
            server.IsStarted.Should().BeFalse();

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

            // Assert
            await act.Should().ThrowAsync <InvalidOperationException>();
        }
Exemplo n.º 3
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();
        }