public async Task GetAllAsync() { // Arrange var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Get, Utils.GetSendGridApiUri(ENDPOINT) + $"?limit=25&offset=0").Respond("application/json", MULTIPLE_INVALID_EMAILS_JSON); var client = Utils.GetFluentClient(mockHttp); var invalidEmails = new InvalidEmails(client); // Act var result = await invalidEmails.GetAllAsync().ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); result.ShouldNotBeNull(); result.Length.ShouldBe(2); }
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_INVALID_EMAILS_JSON) }) .Verifiable(); var invalidEmails = new InvalidEmails(mockClient.Object, ENDPOINT); // Act var result = invalidEmails.GetAllAsync().Result; // Assert result.ShouldNotBeNull(); result.Length.ShouldBe(2); }