public async Task AddAddressToUnsubscribeGroupAsync_multiple_emails() { // Arrange var groupId = 103; var emails = new[] { "*****@*****.**", "*****@*****.**" }; var apiResponse = @"{ 'recipient_emails': [ '*****@*****.**', '*****@*****.**' ] }" ; var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Post, Utils.GetSendGridApiUri(ENDPOINT, "groups", groupId, "suppressions")).Respond("application/json", apiResponse); var client = Utils.GetFluentClient(mockHttp); var suppressions = new Suppressions(client); // Act await suppressions.AddAddressToUnsubscribeGroupAsync(groupId, emails, CancellationToken.None).ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); }
public void AddAddressToUnsubscribeGroup_multiple_emails() { // Arrange var groupId = 103; var emails = new[] { "*****@*****.**", "*****@*****.**" }; var apiResponse = @"{ 'recipient_emails': [ '*****@*****.**', '*****@*****.**' ] }" ; var mockClient = new Mock <IClient>(MockBehavior.Strict); mockClient.Setup(c => c.PostAsync($"{ENDPOINT}/{groupId}/suppressions", It.Is <JObject>(o => o["recipient_emails"].ToObject <JArray>().Count == emails.Length), It.IsAny <CancellationToken>())) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(apiResponse) }); var suppressions = new Suppressions(mockClient.Object); // Act suppressions.AddAddressToUnsubscribeGroupAsync(groupId, emails, CancellationToken.None).Wait(); // Assert }