public void Should_raise_IdentityServiceApiException_on_unsuccessful_response_on_delete() { _secureHttpRequest.Setup(x => x.DeleteAsync(It.IsAny <string>(), It.IsAny <string>())) .ReturnsAsync(ApiRequestHelper.CreateHttpResponseMessage("test", HttpStatusCode.Unauthorized)); var exception = Assert.ThrowsAsync <IdentityServiceApiException>(async() => await _client.DeleteUserAsync(UserName)); exception.Should().NotBeNull(); exception.Message.Should().Be("Failed to call API: Unauthorized\r\ntest"); }