public void Test_Delete_Fail() { const string expectedUri = @"https://test.com/delete"; var status = new StatusResponse(); status.Error = "FooError"; status.Errors.Add(new ErrorMessage { error_message = "BarError" }); var response = new ApiResponse <StatusResponse>(HttpStatusCode.NotFound, "Not Found"); response.Data = status; var gatewayMock = new Mock <ISoundCloudApiGateway>(MockBehavior.Strict); gatewayMock.Setup(x => x.InvokeDeleteRequest <StatusResponse>(It.Is <Uri>(y => y.ToString() == expectedUri))).Returns(response); var endpoint = new TestEndpoint(gatewayMock.Object); var result = endpoint.Delete(expectedUri); Assert.That(result, Is.InstanceOf <ErrorWebResult <object> >()); Assert.That(result.IsSuccess, Is.False); Assert.That(result.ErrorMessage, Is.EqualTo("FooError\r\nBarError")); }
public void Test_Delete_Success() { const string expectedUri = @"https://test.com/delete"; var response = new ApiResponse <StatusResponse>(HttpStatusCode.OK, "OK"); var gatewayMock = new Mock <ISoundCloudApiGateway>(MockBehavior.Strict); gatewayMock.Setup(x => x.InvokeDeleteRequest <StatusResponse>(It.Is <Uri>(y => y.ToString() == expectedUri))).Returns(response); var endpoint = new TestEndpoint(gatewayMock.Object); var result = endpoint.Delete(expectedUri); Assert.That(result, Is.InstanceOf <SuccessWebResult <object> >()); Assert.That(result.IsSuccess, Is.True); Assert.That(result.ErrorMessage, Is.EqualTo(string.Empty)); }