Ejemplo n.º 1
0
        public async Task GetAllAsync()
        {
            // Arrange
            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(HttpMethod.Get, Utils.GetSendGridApiUri(ENDPOINT) + $"?limit=25&offset=0").Respond("application/json", MULTIPLE_SPAM_REPORTS_JSON);

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

            // Act
            var result = await spamReports.GetAllAsync().ConfigureAwait(false);

            // Assert
            mockHttp.VerifyNoOutstandingExpectation();
            mockHttp.VerifyNoOutstandingRequest();
            result.ShouldNotBeNull();
            result.Length.ShouldBe(2);
        }
Ejemplo n.º 2
0
        public void GetAll()
        {
            // Arrange
            var mockRepository = new MockRepository(MockBehavior.Strict);
            var mockClient     = mockRepository.Create <IClient>();

            mockClient
            .Setup(c => c.GetAsync($"{ENDPOINT}?start_time=&end_time=&limit=25&offset=0", It.IsAny <CancellationToken>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MULTIPLE_SPAM_REPORTS_JSON)
            })
            .Verifiable();

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

            // Act
            var result = spamReports.GetAllAsync().Result;

            // Assert
            result.ShouldNotBeNull();
            result.Length.ShouldBe(2);
        }