public void Remove_NonExistingId_ErrorResult() { const int testId = 11; Code testCode = null; mockUnitOfWork.Setup(m => m.Codes.GetById(It.Is <int>(x => x == testId))).Returns(testCode); mockUnitOfWork.Setup(m => m.Save()); var result = manager.Remove(testId); TestContext.WriteLine(result.Details); Assert.That(result.Success, Is.False); }
/// <summary> /// Remove code with specified codeId. Uses pageStateJson for simplicity /// </summary> public IActionResult Remove(int codeId, string pageStateJson) { PageState pageState = JsonConvert.DeserializeObject <PageState>(pageStateJson); var result = codeManager.Remove(codeId); if (!result.Success) { TempData["ErrorMessage"] = result.Details; return(Redirect(Url.Action("Codes", pageState))); } else { return(Redirect(Url.Action("Codes", pageState))); } }