コード例 #1
0
        public async Task Proceeds_On_200()
        {
            CancellationToken   cancellationToken   = new CancellationToken();
            HttpResponseMessage unsuccesfulResponse =
                fixture.Build <HttpResponseMessage>().With(r => r.StatusCode, HttpStatusCode.OK).Create();
            FitbitHttpErrorHandler sut = fixture.Create <FitbitHttpErrorHandler>();

            HttpResponseMessage result = await sut.InterceptResponse(Task.FromResult(unsuccesfulResponse), cancellationToken, null);

            //A null response means the interceptor is letting the pipeline continue its normal flow.
            Assert.IsNull(result);
        }
コード例 #2
0
        public void Throws_On_500()
        {
            CancellationToken   cancellationToken   = new CancellationToken();
            HttpResponseMessage unsuccesfulResponse =
                fixture.Build <HttpResponseMessage>().With(r => r.StatusCode, HttpStatusCode.InternalServerError).Create();
            FitbitHttpErrorHandler sut = fixture.Create <FitbitHttpErrorHandler>();

            Assert.That(
                new AsyncTestDelegate(async() => await sut.InterceptResponse(Task.FromResult(unsuccesfulResponse), cancellationToken, null)),
                Throws.InstanceOf <FitbitRequestException>()
                );
        }