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