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

            Mock.Get(client)
            .Verify(p => p.SendAsync <AssociationIdList>(HttpMethod.Get, $"/crm-associations/v1/associations/{objectId}/HUBSPOT_DEFINED/{associationTypeId}", It.IsAny <IQueryString>()));
        }
        public async Task Request_is_correct([Frozen] IHttpRestClient client, IHubSpotCrmAssociationClient sut, Association associationToDelete)
        {
            await sut.DeleteAsync(associationToDelete);

            Mock.Get(client)
            .Verify(p => p.SendAsync(HttpMethod.Put, "/crm-associations/v1/associations/delete", associationToDelete, null));
        }
        public async Task Request_is_correct([Frozen] IHttpRestClient client, IHubSpotCrmAssociationClient sut, [MaxLength(100)] IReadOnlyList <Association> associationsToCreate)
        {
            await sut.CreateManyAsync(associationsToCreate);

            Mock.Get(client)
            .Verify(p => p.SendAsync(HttpMethod.Put, "/crm-associations/v1/associations/create-batch", associationsToCreate, null));
        }
        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}"))));
        }
 public void Limit_cant_be_greater_than_100(IHubSpotCrmAssociationClient sut, long objectId, int associationTypeId, int limit)
 {
     Assert.ThrowsAsync <ArgumentOutOfRangeException>(() => sut.GetAllAsync(objectId, associationTypeId, limit: 100 + limit));
 }
 public void Item_to_create_cant_be_null(IHubSpotCrmAssociationClient sut)
 {
     Assert.That(() => sut.CreateAsync(null), Throws.ArgumentNullException);
 }
 public void Item_to_delete_cant_be_null(IHubSpotCrmAssociationClient sut)
 {
     Assert.ThrowsAsync <ArgumentNullException>(() => sut.DeleteAsync(null));
 }
 public void Batch_size_cant_be_greater_than_100(IHubSpotCrmAssociationClient sut, [MinLength(101)] Association[] associations)
 {
     Assert.ThrowsAsync <ArgumentOutOfRangeException>(() => sut.CreateManyAsync(associations));
 }
        public async Task No_request_is_sent_if_associations_is_empty([Frozen] IHttpRestClient client, IHubSpotCrmAssociationClient sut)
        {
            await sut.CreateManyAsync(new Association[0]);

            Mock.Get(client)
            .Verify(p => p.SendAsync(It.IsAny <HttpMethod>(), "/crm-associations/v1/associations/create-batch", It.IsAny <Association[]>(), null), Times.Never());
        }
 public void Associations_cant_be_null(IHubSpotCrmAssociationClient sut)
 {
     Assert.ThrowsAsync <ArgumentNullException>(() => sut.CreateManyAsync(associations: null));
 }