Esempio n. 1
0
        public void Delete_and_delete_contacts()
        {
            // Arrange
            var segmentId      = 1;
            var deleteContacts = true;

            var mockClient = new Mock <IClient>(MockBehavior.Strict);

            mockClient.Setup(c => c.DeleteAsync($"{ENDPOINT}/{segmentId}?delete_contacts=true", It.IsAny <CancellationToken>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.NoContent));

            var segments = new Segments(mockClient.Object);

            // Act
            segments.DeleteAsync(segmentId, deleteContacts, CancellationToken.None).Wait(CancellationToken.None);

            // Assert
        }
Esempio n. 2
0
        public async Task DeleteAsync_and_delete_contacts()
        {
            // Arrange
            var segmentId      = 1;
            var deleteContacts = true;

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(HttpMethod.Delete, Utils.GetSendGridApiUri(ENDPOINT, segmentId) + "?delete_contacts=true").Respond(HttpStatusCode.NoContent);

            var client   = Utils.GetFluentClient(mockHttp);
            var segments = new Segments(client);

            // Act
            await segments.DeleteAsync(segmentId, deleteContacts, null, CancellationToken.None).ConfigureAwait(false);

            // Assert
            mockHttp.VerifyNoOutstandingExpectation();
            mockHttp.VerifyNoOutstandingRequest();
        }
Esempio n. 3
0
        public void Delete_and_preserve_contacts()
        {
            // Arrange
            var segmentId      = 1;
            var deleteContacts = false;

            var mockRepository = new MockRepository(MockBehavior.Strict);
            var mockClient     = mockRepository.Create <IClient>();

            mockClient
            .Setup(c => c.DeleteAsync($"{ENDPOINT}/{segmentId}?delete_contacts=false", It.IsAny <CancellationToken>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.NoContent))
            .Verifiable();

            var segments = new Segments(mockClient.Object, ENDPOINT);

            // Act
            segments.DeleteAsync(segmentId, deleteContacts, CancellationToken.None).Wait(CancellationToken.None);

            // Assert
        }