public void Delete() { // Arrange var identityId = 1; var mockClient = new Mock <IClient>(MockBehavior.Strict); mockClient.Setup(c => c.DeleteAsync($"{ENDPOINT}/{identityId}", It.IsAny <CancellationToken>())) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.NoContent)); var senderIdentities = new SenderIdentities(mockClient.Object); // Act senderIdentities.DeleteAsync(identityId, CancellationToken.None).Wait(CancellationToken.None); // Assert }
public async Task DeleteAsync() { // Arrange var identityId = 1; var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Delete, Utils.GetSendGridApiUri(ENDPOINT, identityId)).Respond(HttpStatusCode.NoContent); var client = Utils.GetFluentClient(mockHttp); var senderIdentities = new SenderIdentities(client); // Act await senderIdentities.DeleteAsync(identityId, null, CancellationToken.None).ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); }