Beispiel #1
0
        public async Task GetDataFromApi_ResponseContentIsEmpty_ThrowsNullReferenceException()
        {
            var responseMock = CreateResponseMock();

            responseMock.Setup(x => x.Content).Returns("");
            var clientMock = CreateRestClientMock(responseMock.Object);
            var handler    = new RestRepositoryTests(clientMock.Object, "");

            await Assert.ThrowsAnyAsync <NullReferenceException>(() => handler.GetDataFromApi());
        }
Beispiel #2
0
        public async Task GetDataFromApi_RequestWasNotSuccessful_ThrowsHttpRequestException()
        {
            var responseMock = CreateResponseMock();

            responseMock.Setup(x => x.IsSuccessful).Returns(false);
            var clientMock = CreateRestClientMock(responseMock.Object);
            var handler    = new RestRepositoryTests(clientMock.Object, "");

            await Assert.ThrowsAnyAsync <HttpRequestException>(() => handler.GetDataFromApi());
        }
Beispiel #3
0
        public async Task GetDataFromApi_WorksProperly()
        {
            var responseMock = CreateResponseMock();
            var clientMock   = CreateRestClientMock(responseMock.Object);
            var handler      = new RestRepositoryTests(clientMock.Object, "");

            var result = await handler.GetDataFromApi();

            Assert.NotNull(result);
        }