Ejemplo n.º 1
0
        public void AddRecipient()
        {
            // Arrange
            var listId    = 1;
            var contactId = "abc123";

            var mockClient = new Mock <IClient>(MockBehavior.Strict);

            mockClient.Setup(c => c.PostAsync($"{ENDPOINT}/{listId}/recipients/{contactId}", (JObject)null, It.IsAny <CancellationToken>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.Created));

            var lists = new Lists(mockClient.Object);

            // Act
            lists.AddRecipientAsync(listId, contactId, CancellationToken.None).Wait();

            // Assert
        }
Ejemplo n.º 2
0
        public async Task AddRecipientAsync()
        {
            // Arrange
            var listId    = 1;
            var contactId = "abc123";

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(HttpMethod.Post, Utils.GetSendGridApiUri(ENDPOINT, listId, "recipients", contactId)).Respond(HttpStatusCode.Created);

            var client = Utils.GetFluentClient(mockHttp);
            var lists  = new Lists(client);

            // Act
            await lists.AddRecipientAsync(listId, contactId, CancellationToken.None).ConfigureAwait(false);

            // Assert
            mockHttp.VerifyNoOutstandingExpectation();
            mockHttp.VerifyNoOutstandingRequest();
        }