Exemplo n.º 1
0
        public void Can_set_timeout_from_settings()
        {
            HttpClient httpClient = A.HttpClient;
            Alive      sut        = A.Alive.With(httpClient);

            sut.HttpPing("http://url", new AliveSettings {
                Timeout = 1
            });

            Assert.Equal(httpClient.Timeout, TimeSpan.FromMilliseconds(1));
        }
Exemplo n.º 2
0
        public void Can_handle_responses_with_an_unsuccessful_status_code()
        {
            Alive sut = A.Alive
                        .With(A.HttpClient
                              .With(A.HttpResponseMessage
                                    .WithStatus(HttpStatusCode.BadRequest)
                                    )
                              );

            Assert.Throws <NotAliveException>(() => sut.HttpPing("http://url", new AliveSettings()));
        }
Exemplo n.º 3
0
        public void Settings_must_not_be_null()
        {
            Alive sut = A.Alive;

            Assert.Throws <ArgumentNullException>(() => sut.HttpPing("url", null));
        }
Exemplo n.º 4
0
        public void Url_must_not_be_null_or_empty(string url)
        {
            Alive sut = A.Alive;

            Assert.Throws <ArgumentException>(() => sut.HttpPing(url, new AliveSettings()));
        }
Exemplo n.º 5
0
        public void Can_handle_exceptions()
        {
            Alive sut = A.Alive.With(new FakeHttpClient(new Exception()));

            Assert.Throws <NotAliveException>(() => sut.HttpPing("http://url", new AliveSettings()));
        }
Exemplo n.º 6
0
        public void Can_handle_responses_with_an_successful_status_code()
        {
            Alive sut = A.Alive;

            sut.HttpPing("http://url", new AliveSettings());
        }