public void Details_Test() { CC.Data.Tests.Helper.PrepareTestData(); ClientsController target = new ClientsController(); // TODO: Initialize to an appropriate value User ccUser = CC.Data.Tests.Helper.GetAdminUser(); var mocks = new ContextMocks(target, true, false); target.CcUser = ccUser; Client cc = CC.Data.Tests.Helper.GetClient("Client1"); Nullable <int> id = cc.Id; Nullable <bool> newClient = false; ViewResult actual = target.Details(id, newClient); Assert.IsNotNull(actual, " view result can not be null"); System.Web.Mvc.ViewResultBase viewResult = (System.Web.Mvc.ViewResultBase)actual; ViewDataDictionary data = viewResult.ViewData; Assert.IsNotNull(data.Keys.Count() == 3, "must be 3 dataitems: client data, agencies, permissions"); Client cl = (Client)data.Model; Assert.IsTrue(cl.Id == cc.Id && cl.FirstName == "Client1", " must open detail of client with name " + cc.FirstName); //now write the same test for user, that not have permissions for this client" }
public void IndexTest_TryUpdateStatus_NotSelectedClients() { //try to change approval status without select clients target = GetTarget_ForUser(FixedRoles.Admin); mocks = new ContextMocks(target, true, false); ClientsListModel model = new ClientsListModel(); model.UpdateModel.SelectedClientIds = null; model.UpdateModel.NewApprovalStatusId = (int)ApprovalStatusEnum.Approved; ActionResult actual = target.Index(model); Assert.IsNotNull(actual, "action result can not be null"); string content = ((System.Web.Mvc.ContentResult)actual).Content; Assert.IsTrue(content == "selection is empty", "result must be:selection is empty"); }