public async Task Offset_is_correctly_added_to_queryString([Frozen] IHttpRestClient client, IHubSpotCrmAssociationClient sut, long objectId, int associationTypeId, long offset)
        {
            var response = await sut.GetAllAsync(objectId, associationTypeId, offset : offset);

            Mock.Get(client)
            .Verify(p => p.SendAsync <AssociationIdList>(HttpMethod.Get, $"/crm-associations/v1/associations/{objectId}/HUBSPOT_DEFINED/{associationTypeId}", QueryStringMatcher.That(Contains.Substring($"offset={offset}"))));
        }
示例#2
0
        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 Limit_is_correctly_added_to_queryString([Frozen] IHttpRestClient client, IHubSpotCrmAssociationClient sut, long objectId, int associationTypeId, [System.ComponentModel.DataAnnotations.Range(1, 100)] int limit)
        {
            Assume.That(limit <= 100);

            var response = await sut.GetAllAsync(objectId, associationTypeId, limit);

            Mock.Get(client)
            .Verify(p => p.SendAsync <AssociationIdList>(HttpMethod.Get, $"/crm-associations/v1/associations/{objectId}/HUBSPOT_DEFINED/{associationTypeId}", QueryStringMatcher.That(Contains.Substring($"limit={limit}"))));
        }
示例#4
0
        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}")))));
        }
示例#5
0
        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}"))));
        }
示例#6
0
        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 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 async Task Several_contacts_are_returned([Frozen] IHttpRestClient client, IHubSpotOwnerClient sut, Owner[] owners)
        {
            Mock.Get(client)
            .Setup(p => p.SendAsync <IReadOnlyList <Owner> >(HttpMethod.Get, "/owners/v2/owners/", It.IsAny <IQueryString>()))
            .ReturnsAsync(owners);

            var response = await sut.GetManyAsync();

            Mock.Get(client).Verify(p => p.SendAsync <IReadOnlyList <Owner> >(HttpMethod.Get, "/owners/v2/owners/", QueryStringMatcher.That(Does.Not.Contain("email"))));
        }
        public async Task Email_address_is_appended_to_query_to_filter_by_email([Frozen] IHttpRestClient client, IHubSpotOwnerClient sut, Owner owner)
        {
            Mock.Get(client)
            .Setup(p => p.SendAsync <IReadOnlyList <Owner> >(HttpMethod.Get, "/owners/v2/owners/", It.IsAny <IQueryString>()))
            .ReturnsAsync(new[] { owner });

            var response = await sut.GetManyAsync(owner.Email);

            Mock.Get(client).Verify(p => p.SendAsync <IReadOnlyList <Owner> >(HttpMethod.Get, "/owners/v2/owners/", QueryStringMatcher.That(Contains.Substring($"email={owner.Email}"))));
        }
示例#10
0
        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}")))));
        }