public async Task Request_is_correct([Frozen] IHttpRestClient client, IHubSpotContactClient sut) { var response = await sut.GetRecentlyUpdatedAsync(); Mock.Get(client) .Verify(p => p.SendAsync <ContactList>(HttpMethod.Get, "/contacts/v1/lists/recently_updated/contacts/recent", It.IsAny <IQueryString>())); }
public async Task Request_is_correct([Frozen] IHttpRestClient client, IHubSpotContactClient sut, string query) { var response = await sut.SearchAsync(query); Mock.Get(client) .Verify(p => p.SendAsync <SearchResponse>(HttpMethod.Get, "/contacts/v1/search/query", It.IsAny <IQueryString>())); }
public async Task Request_is_correct([Frozen] IHttpRestClient client, IHubSpotContactClient sut, long contactId, IReadOnlyList <ValuedProperty> properties) { await sut.UpdateByIdAsync(contactId, properties); Mock.Get(client) .Verify(p => p.SendAsync(HttpMethod.Post, $"/contacts/v1/contact/vid/{contactId}/profile", PropertyList.Contains(properties), null)); }
public async Task Request_is_correct([Frozen] IHttpRestClient client, IHubSpotContactClient sut, string userToken, Contact contact) { Mock.Get(client) .Setup(p => p.SendAsync <Contact>(HttpMethod.Get, $"/contacts/v1/contact/utk/{userToken}/profile", It.IsAny <IQueryString>())) .ReturnsAsync(contact) .Verifiable(); var response = await sut.GetByUserTokenAsync(userToken); Mock.Verify(); }
public async Task Request_is_correct([Frozen] IHttpRestClient client, IHubSpotContactClient sut, long[] contactIds, Dictionary <long, Contact> contacts) { Mock.Get(client) .Setup(p => p.SendAsync <Dictionary <long, Contact> >(HttpMethod.Get, "/contacts/v1/contact/vids/batch/", It.IsAny <IQueryString>())) .ReturnsAsync(contacts) .Verifiable(); var response = await sut.GetManyByIdAsync(contactIds); Mock.Verify(); }
public async Task Request_is_correct([Frozen] IHttpRestClient client, IHubSpotContactClient sut, string email, IReadOnlyList <ValuedProperty> properties, CreateOrUpdateResponse response) { Mock.Get(client) .Setup(p => p.SendAsync <PropertyList <ValuedProperty>, CreateOrUpdateResponse>(HttpMethod.Post, It.Is <string>(s => s.StartsWith($"/contacts/v1/contact/createOrUpdate/email/")), It.IsAny <PropertyList <ValuedProperty> >(), null)) .ReturnsAsync(response); await sut.CreateOrUpdateByEmailAsync(email, properties); Mock.Get(client) .Verify(p => p.SendAsync <PropertyList <ValuedProperty>, CreateOrUpdateResponse>(HttpMethod.Post, $"/contacts/v1/contact/createOrUpdate/email/{email}", PropertyList.Contains(properties), null)); }
public async Task Request_is_correct([Frozen] IHttpRestClient client, IHubSpotContactClient sut, Contact contact) { var properties = (from p in contact.Properties select new ValuedProperty(p.Key, p.Value.Value)).ToArray(); Mock.Get(client) .Setup(p => p.SendAsync <PropertyList <ValuedProperty>, Contact>(HttpMethod.Post, "/contacts/v1/contact", It.IsAny <PropertyList <ValuedProperty> >(), null)) .ReturnsAsync(contact) .Verifiable(); var response = await sut.CreateAsync(properties); Mock.Get(client).Verify(); }
public async Task Returns_empty_dictionary_if_no_id(IHubSpotContactClient sut) { var response = await sut.GetManyByIdAsync(Array.Empty <long>()); Assert.That(response, Is.Empty); }
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 void Throws_OutOfRange_if_more_than_100(int count, IHubSpotContactClient sut) { var emails = new string[count]; Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => await sut.GetManyByEmailAsync(emails)); }
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}"))))); }
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 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 Request_is_correct([Frozen] IHttpRestClient client, IHubSpotContactClient sut, long primaryContactId, long secondaryContactId) { await sut.MergeAsync(primaryContactId, secondaryContactId); Mock.Get(client).Verify(p => p.SendAsync <object>(HttpMethod.Post, $"/contacts/v1/contact/merge-vids/{primaryContactId}/", It.IsAny <object>(), null)); }
public async Task Query_is_attached_to_request([Frozen] IHttpRestClient client, IHubSpotContactClient sut, string query) { var response = await sut.SearchAsync(query); Mock.Get(client) .Verify(p => p.SendAsync <SearchResponse>(HttpMethod.Get, "/contacts/v1/search/query", QueryStringMatcher.That(Does.Contain($"q={query}")))); }
public async Task Returns_empty_dictionary_if_null(IHubSpotContactClient sut) { var response = await sut.GetManyByIdAsync(null); Assert.That(response, Is.Empty); }
public void Throws_OutOfRange_if_more_than_100(int count, IHubSpotContactClient sut) { var contactIds = new long[count]; Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => await sut.GetManyByIdAsync(contactIds)); }
public async Task Emails_are_attached_to_request([Frozen] IHttpRestClient client, IHubSpotContactClient sut, string[] emails, Dictionary <long, Contact> contacts) { Mock.Get(client) .Setup(p => p.SendAsync <Dictionary <long, Contact> >(HttpMethod.Get, "/contacts/v1/contact/emails/batch/", It.IsAny <IQueryString>())) .ReturnsAsync(contacts); var response = await sut.GetManyByEmailAsync(emails); Mock.Get(client) .Verify(p => p.SendAsync <Dictionary <long, Contact> >(HttpMethod.Get, "/contacts/v1/contact/emails/batch/", QueryStringMatcher.That(NUnitHelpers.All(emails, email => Does.Contain($"email={email}"))))); }
public async Task Ids_are_attached_to_request([Frozen] IHttpRestClient client, IHubSpotContactClient sut, long[] contactIds, Dictionary <long, Contact> contacts) { Mock.Get(client) .Setup(p => p.SendAsync <Dictionary <long, Contact> >(HttpMethod.Get, "/contacts/v1/contact/vids/batch/", It.IsAny <IQueryString>())) .ReturnsAsync(contacts); var response = await sut.GetManyByIdAsync(contactIds); Mock.Get(client) .Verify(p => p.SendAsync <Dictionary <long, Contact> >(HttpMethod.Get, "/contacts/v1/contact/vids/batch/", QueryStringMatcher.That(All(contactIds, id => Does.Contain($"vid={id}"))))); }
public void Email_is_required(IHubSpotContactClient sut) { Assert.That(() => sut.GetByEmailAsync(null), Throws.ArgumentNullException); }
public async Task Request_is_correct([Frozen] IHttpRestClient client, IHubSpotContactClient sut, long contactId) { var actual = await sut.DeleteAsync(contactId); Mock.Get(client).Verify(p => p.SendAsync <DeleteContactResponse>(HttpMethod.Delete, $"/contacts/v1/contact/vid/{contactId}", null)); }
public async Task Request_is_correct([Frozen] IHttpRestClient client, IHubSpotContactClient sut, string email) { var response = await sut.GetByEmailAsync(email); Mock.Get(client).Verify(p => p.SendAsync <Contact>(HttpMethod.Get, $"/contacts/v1/contact/email/{email}/profile", It.IsAny <IQueryString>())); }