public void GetUnsubscribedAddresses()
        {
            // Arrange
            var groupId = 123;

            var apiResponse = @"[
				'*****@*****.**',
				'*****@*****.**'
			]"            ;
            var mockClient  = new Mock <IClient>(MockBehavior.Strict);

            mockClient.Setup(c => c.GetAsync($"{ENDPOINT}/{groupId}/suppressions", It.IsAny <CancellationToken>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(apiResponse)
            });

            var suppresions = new Suppressions(mockClient.Object);

            // Act
            var result = suppresions.GetUnsubscribedAddressesAsync(groupId, CancellationToken.None).Result;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Length);
            Assert.AreEqual("*****@*****.**", result[0]);
            Assert.AreEqual("*****@*****.**", result[1]);
        }
        public async Task GetUnsubscribedAddressesAsync()
        {
            // Arrange
            var groupId = 123;

            var apiResponse = @"[
				'*****@*****.**',
				'*****@*****.**'
			]"            ;

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(HttpMethod.Get, Utils.GetSendGridApiUri(ENDPOINT, "groups", groupId, "suppressions")).Respond("application/json", apiResponse);

            var client      = Utils.GetFluentClient(mockHttp);
            var suppresions = new Suppressions(client);

            // Act
            var result = await suppresions.GetUnsubscribedAddressesAsync(groupId, CancellationToken.None).ConfigureAwait(false);

            // Assert
            mockHttp.VerifyNoOutstandingExpectation();
            mockHttp.VerifyNoOutstandingRequest();
            result.ShouldNotBeNull();
            result.Length.ShouldBe(2);
            result[0].ShouldBe("*****@*****.**");
            result[1].ShouldBe("*****@*****.**");
        }
Beispiel #3
0
        public void GetUnsubscribedAddresses()
        {
            // Arrange
            var groupId = 123;

            var apiResponse = @"[
				'*****@*****.**',
				'*****@*****.**'
			]"            ;

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

            mockClient
            .Setup(c => c.GetAsync($"{ENDPOINT}/{groupId}/suppressions", It.IsAny <CancellationToken>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(apiResponse)
            })
            .Verifiable();

            var suppresions = new Suppressions(mockClient.Object, ENDPOINT);

            // Act
            var result = suppresions.GetUnsubscribedAddressesAsync(groupId, CancellationToken.None).Result;

            // Assert
            result.ShouldNotBeNull();
            result.Length.ShouldBe(2);
            result[0].ShouldBe("*****@*****.**");
            result[1].ShouldBe("*****@*****.**");
        }