public async Task GetAsync() { // Arrange var emailAddress = "*****@*****.**"; var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Get, Utils.GetSendGridApiUri(ENDPOINT, emailAddress)).Respond("application/json", MULTIPLE_INVALID_EMAILS_JSON); var client = Utils.GetFluentClient(mockHttp); var invalidEmails = new InvalidEmails(client); // Act var result = await invalidEmails.GetAsync(emailAddress, null, CancellationToken.None).ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); result.ShouldNotBeNull(); result.Length.ShouldBe(2); }
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(MULTIPLE_INVALID_EMAILS_JSON) }) .Verifiable(); var invalidEmails = new InvalidEmails(mockClient.Object, ENDPOINT); // Act var result = invalidEmails.GetAsync(emailAddress, CancellationToken.None).Result; // Assert result.ShouldNotBeNull(); result.Length.ShouldBe(2); }