public void Test_GetList_Fail() { const string expectedUri = @"https://test.com/get"; var response = new ApiResponse <PagedResult <TestEntity> >(HttpStatusCode.NotFound, "Not Found"); var gatewayMock = new Mock <ISoundCloudApiGateway>(MockBehavior.Strict); gatewayMock.Setup(x => x.InvokeGetRequest <PagedResult <TestEntity> >(It.Is <Uri>(y => y.ToString() == expectedUri))).Returns(response); var endpoint = new TestEndpoint(gatewayMock.Object); var result = endpoint.GetList <TestEntity>(expectedUri); Assert.That(result, Is.Empty); }
public void Test_GetList_Success() { const string expectedUri = @"https://test.com/get"; var testEntities = new PagedResult <TestEntity>(); testEntities.collection.Add(new TestEntity()); var response = new ApiResponse <PagedResult <TestEntity> >(HttpStatusCode.OK, "OK"); response.Data = testEntities; var gatewayMock = new Mock <ISoundCloudApiGateway>(MockBehavior.Strict); gatewayMock.Setup(x => x.InvokeGetRequest <PagedResult <TestEntity> >(It.Is <Uri>(y => y.ToString() == expectedUri))).Returns(response); var endpoint = new TestEndpoint(gatewayMock.Object); var result = endpoint.GetList <TestEntity>(expectedUri).ToList(); Assert.That(result[0], Is.EqualTo(testEntities.collection[0])); }