Example #1
0
        public void Get()
        {
            // Arrange
            var emailAddress = "*****@*****.**";

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

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

            var spamReports = new SpamReports(mockClient.Object, ENDPOINT);

            // Act
            var result = spamReports.GetAsync(emailAddress, CancellationToken.None).Result;

            // Assert
            result.ShouldNotBeNull();
            result.Length.ShouldBe(1);
        }
Example #2
0
        public async Task GetAsync()
        {
            // Arrange
            var emailAddress = "*****@*****.**";

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(HttpMethod.Get, Utils.GetSendGridApiUri(ENDPOINT, emailAddress)).Respond("application/json", SINGLE_SPAM_REPORT_JSON);

            var client      = Utils.GetFluentClient(mockHttp);
            var spamReports = new SpamReports(client);

            // Act
            var result = await spamReports.GetAsync(emailAddress, null, CancellationToken.None).ConfigureAwait(false);

            // Assert
            mockHttp.VerifyNoOutstandingExpectation();
            mockHttp.VerifyNoOutstandingRequest();
            result.ShouldNotBeNull();
            result.Length.ShouldBe(1);
        }