public void ThenThrowException() { //arrange var model = new CertificateConfirmDeleteViewModel { IncidentNumber = _deleteViewModel.IncidentNumber, ReasonForChange = _deleteViewModel.ReasonForChange, StandardCode = 153, Uln = 1234456, Username = "******" }; Mock <ICertificateApiClient> client = new Mock <ICertificateApiClient>(); client.Setup(c => c.Delete(It.IsAny <DeleteCertificateRequest>())).Throws(new HttpRequestException()); _sut = new CertificateDeleteController(MockedLogger.Object, MockHttpContextAccessor.Object, ApiClient, client.Object); try { //act _result = _sut.SuccessfulDelete(model).GetAwaiter().GetResult(); } catch (Exception ex) { //assert Assert.IsTrue(ex is HttpRequestException); } }
public void Arrange() { _deleteViewModel = new CertificateDeleteViewModel() { CertificateId = Certificate.Id, IncidentNumber = "INC123", ReasonForChange = "chnage required" }; _sut = new CertificateDeleteController(MockedLogger.Object, MockHttpContextAccessor.Object, ApiClient, CertificateApiClient); }