public async Task GetByGuidAsync_returns_pipeline_with_valid_guid([Frozen] IHttpRestClient httpRestClient, IHubSpotPipelineClient sut, string guid, IFixture fixture) { //Arrange var pipeline = fixture.Build <Pipeline>().With(x => x.Guid, guid).Create(); Mock.Get(httpRestClient) .Setup(p => p.SendAsync <Pipeline>(HttpMethod.Get, $"/deals/v1/pipelines/{guid}", null)).Returns(Task.FromResult(pipeline)); //Act var result = await sut.GetByGuidAsync(guid); //Assert Assert.That(result.Guid, Is.EqualTo(guid)); }
public async Task GetByGuidAsync_returns_pipeline_retrieved_by_http_client_request([Frozen] IHttpRestClient httpRestClient, [Frozen] Pipeline pipeline, IHubSpotPipelineClient sut, string guid) { //Arrange Mock.Get(httpRestClient) .Setup(p => p.SendAsync <Pipeline>(HttpMethod.Get, $"/deals/v1/pipelines/{guid}", null)).Returns(Task.FromResult(pipeline)); //Act var result = await sut.GetByGuidAsync(guid); //Assert Assert.That(result, Is.EqualTo(pipeline)); }
public void GetByGuidAsync_invokes_http_client_get_method_once_with_guid([Frozen] IHttpRestClient httpRestClient, IHubSpotPipelineClient sut, string guid) { //Arrange //Act sut.GetByGuidAsync(guid); //Assert Mock.Get(httpRestClient).Verify(p => p.SendAsync <Pipeline>(HttpMethod.Get, $"/deals/v1/pipelines/{guid}", null), Times.Once); }
public async Task GetByGuidAsync_returns_null_if_API_retrieves_null([Frozen] IHttpRestClient httpRestClient, IHubSpotPipelineClient sut, string guid) { //Arrange Mock.Get(httpRestClient) .Setup(p => p.SendAsync <Pipeline>(HttpMethod.Get, $"/deals/v1/pipelines/{guid}", null)).Returns(Task.FromResult((Pipeline)null)); //Act var result = await sut.GetByGuidAsync(guid); //Assert Assert.That(result, Is.Null); }
public void GetByGuidAsync_throws_NotFoundException_if_request_returns_NotFound_status([Frozen] IHttpRestClient httpRestClient, IHubSpotPipelineClient sut, string guid, IFixture fixture) { //Arrange var httpException = fixture.Build <HttpException>().With(x => x.StatusCode, HttpStatusCode.NotFound).Create(); Mock.Get(httpRestClient) .Setup(p => p.SendAsync <Pipeline>(HttpMethod.Get, $"/deals/v1/pipelines/{guid}", null)) .Throws(httpException); //Act //Assert Assert.That(() => sut.GetByGuidAsync(guid), Throws.InstanceOf <NotFoundException>()); }