Beispiel #1
0
        private bool Test(string expected, string actual)
        {
            var sut = new QueryStringMatcher(expected);

            return(sut.Matches(new HttpRequestMessage(HttpMethod.Get,
                                                      "http://tempuri.org/home?" + actual)));
        }
Beispiel #2
0
        public void Should_support_matching_dictionary_data_with_url_encoded_values()
        {
            var data = new Dictionary <string, string>();

            data.Add("key", "Value with spaces");

            var qs = "key=Value+with%20spaces";

            var sut = new QueryStringMatcher(data);

            var actualMatch = sut.Matches(new HttpRequestMessage(HttpMethod.Get, "http://tempuri.org/home?" + qs));

            Assert.True(actualMatch, "QueryStringMatcher.Matches() should match dictionary data with URL encoded query string values.");
        }
        public void Should_support_matching_dictionary_data_with_url_encoded_values()
        {
            var data = new Dictionary<string, string>();
            data.Add("key", "Value with spaces");

            var qs = "key=Value+with%20spaces";

            var sut = new QueryStringMatcher(data);

            var actualMatch = sut.Matches(new HttpRequestMessage(HttpMethod.Get, "http://tempuri.org/home?" + qs));

            Assert.True(actualMatch, "QueryStringMatcher.Matches() should match dictionary data with URL encoded query string values.");
        }
        private bool Test(string expected, string actual)
        {
            var sut = new QueryStringMatcher(expected);

            return sut.Matches(new HttpRequestMessage(HttpMethod.Get,
                "http://tempuri.org/home?" + actual));
        }
        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}"))));
        }
        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}"))));
        }
Beispiel #7
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}"))));
        }
Beispiel #8
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}"))));
        }
Beispiel #9
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}")))));
        }
Beispiel #10
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}"))));
        }
Beispiel #14
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}")))));
        }