public void AddRecipients() { // Arrange var listId = 1; var contactIds = new[] { "abc123", "def456" }; var mockClient = new Mock <IClient>(MockBehavior.Strict); mockClient.Setup(c => c.PostAsync($"{ENDPOINT}/{listId}/recipients", It.Is <JArray>(o => o.Count == 2), It.IsAny <CancellationToken>())) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.Created)); var lists = new Lists(mockClient.Object); // Act lists.AddRecipientsAsync(listId, contactIds, CancellationToken.None).Wait(); // Assert }
public async Task AddRecipientsAsync() { // Arrange var listId = 1; var contactIds = new[] { "abc123", "def456" }; var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Post, Utils.GetSendGridApiUri(ENDPOINT, listId, "recipients")).Respond(HttpStatusCode.Created); var client = Utils.GetFluentClient(mockHttp); var lists = new Lists(client); // Act await lists.AddRecipientsAsync(listId, contactIds, CancellationToken.None).ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); }