Exemple #1
0
        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>());
        }
Exemple #2
0
        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();
        }
Exemple #3
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}"))));
        }
Exemple #4
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}"))));
        }
Exemple #5
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}")))));
        }