Exemplo n.º 1
0
        public async Task ApiDataProcessorServiceDeleteReturnsSuccess()
        {
            // arrange
            var expectedResult = HttpStatusCode.Created;

            A.CallTo(() => fakeApiService.DeleteAsync(A <HttpClient> .Ignored, A <Uri> .Ignored)).Returns(expectedResult);

            var apiDataProcessorService = new ApiDataProcessorService(fakeApiService);

            // act
            var result = await apiDataProcessorService.DeleteAsync(A.Fake <HttpClient>(), new Uri("https://somewhere.com")).ConfigureAwait(false);

            // assert
            A.CallTo(() => fakeApiService.DeleteAsync(A <HttpClient> .Ignored, A <Uri> .Ignored)).MustHaveHappenedOnceExactly();
            A.Equals(result, expectedResult);
        }
Exemplo n.º 2
0
        public async Task ApiDataProcessorServiceDeleteReturnsExceptionForNoHttpClient()
        {
            // arrange
            var apiDataProcessorService = new ApiDataProcessorService(fakeApiService);

            // act
            var exceptionResult = await Assert.ThrowsAsync <ArgumentNullException>(async() => await apiDataProcessorService.DeleteAsync(null, new Uri("https://somewhere.com")).ConfigureAwait(false)).ConfigureAwait(false);

            // assert
            A.CallTo(() => fakeApiService.DeleteAsync(A <HttpClient> .Ignored, A <Uri> .Ignored)).MustNotHaveHappened();
            Assert.Equal("Value cannot be null. (Parameter 'httpClient')", exceptionResult.Message);
        }