public void NotFoundException_is_thrown_if_404([Frozen] IHttpRestClient client, IHubSpotContactClient sut, long contactId) { Mock.Get(client) .Setup(p => p.SendAsync <Contact>(HttpMethod.Get, $"/contacts/v1/contact/vid/{contactId}/profile", It.IsAny <IQueryString>())) .Throws(new HttpException("Not Found", HttpStatusCode.NotFound)); Assert.That(() => sut.GetByIdAsync(contactId), Throws.InstanceOf <NotFoundException>()); }
public async Task Request_absolutePath_is_correct([Frozen] IHttpRestClient client, IHubSpotContactClient sut, long contactId, Contact contact) { Mock.Get(client) .Setup(p => p.SendAsync <Contact>(HttpMethod.Get, $"/contacts/v1/contact/vid/{contactId}/profile", It.IsAny <IQueryString>())) .ReturnsAsync(contact) .Verifiable(); var response = await sut.GetByIdAsync(contactId); Mock.Verify(); }
public async Task ShowListMemberships_is_added_to_queryString(bool showListMemberships, string queryStringValue, [Frozen] IHttpRestClient client, IHubSpotContactClient sut, long contactId, Contact contact) { Mock.Get(client) .Setup(p => p.SendAsync <Contact>(HttpMethod.Get, $"/contacts/v1/contact/vid/{contactId}/profile", It.IsAny <IQueryString>())) .ReturnsAsync(contact) .Verifiable(); var response = await sut.GetByIdAsync(contactId, showListMemberships : showListMemberships); Mock.Get(client) .Verify(p => p.SendAsync <Contact>(HttpMethod.Get, $"/contacts/v1/contact/vid/{contactId}/profile", QueryStringMatcher.That(Does.Contain($"showListMemberships={queryStringValue}")))); }
public async Task FormSubmissionMode_is_added_to_queryString(FormSubmissionMode formSubmissionMode, string queryStringValue, [Frozen] IHttpRestClient client, IHubSpotContactClient sut, long contactId, Contact contact) { Mock.Get(client) .Setup(p => p.SendAsync <Contact>(HttpMethod.Get, $"/contacts/v1/contact/vid/{contactId}/profile", It.IsAny <IQueryString>())) .ReturnsAsync(contact) .Verifiable(); var response = await sut.GetByIdAsync(contactId, formSubmissionMode : formSubmissionMode); Mock.Get(client) .Verify(p => p.SendAsync <Contact>(HttpMethod.Get, $"/contacts/v1/contact/vid/{contactId}/profile", QueryStringMatcher.That(Does.Contain($"formSubmissionMode={queryStringValue}")))); }
public async Task Properties_are_added_to_queryString([Frozen] IHttpRestClient client, IHubSpotContactClient sut, long contactId, Property[] properties, Contact contact) { Mock.Get(client) .Setup(p => p.SendAsync <Contact>(HttpMethod.Get, $"/contacts/v1/contact/vid/{contactId}/profile", It.IsAny <IQueryString>())) .ReturnsAsync(contact) .Verifiable(); var response = await sut.GetByIdAsync(contactId, properties); Mock.Get(client) .Verify(p => p.SendAsync <Contact>(HttpMethod.Get, $"/contacts/v1/contact/vid/{contactId}/profile", QueryStringMatcher.That(NUnitHelpers.All(properties, property => Does.Contain($"property={property.Name}"))))); }