public void Delete_by_multiple_emails() { // Arrange var emails = new[] { "*****@*****.**", "*****@*****.**" }; var mockClient = new Mock <IClient>(MockBehavior.Strict); mockClient.Setup(c => c.DeleteAsync(ENDPOINT, It.Is <JObject>(o => o["emails"].ToObject <JArray>().Count == emails.Length), It.IsAny <CancellationToken>())) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.NoContent)); var bounces = new Bounces(mockClient.Object); // Act bounces.DeleteAsync(emails, CancellationToken.None).Wait(); // Assert }
public void Delete_by_single_email() { // Arrange var email = "*****@*****.**"; var mockClient = new Mock <IClient>(MockBehavior.Strict); mockClient.Setup(c => c.DeleteAsync($"{ENDPOINT}/{email}", It.IsAny <CancellationToken>())) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.NoContent)); var bounces = new Bounces(mockClient.Object); // Act bounces.DeleteAsync(email, CancellationToken.None).Wait(); // Assert }
public async Task DeleteAsync_by_multiple_emails() { // Arrange var emails = new[] { "*****@*****.**", "*****@*****.**" }; var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Delete, Utils.GetSendGridApiUri(ENDPOINT)).Respond(HttpStatusCode.NoContent); var client = Utils.GetFluentClient(mockHttp); var bounces = new Bounces(client); // Act await bounces.DeleteAsync(emails, null, CancellationToken.None).ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); }
public void Delete_by_single_email() { // Arrange var email = "*****@*****.**"; var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Delete, Utils.GetSendGridApiUri(ENDPOINT, email)).Respond(HttpStatusCode.NoContent); var client = Utils.GetFluentClient(mockHttp); var bounces = new Bounces(client); // Act bounces.DeleteAsync(email, CancellationToken.None).Wait(); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); }