public void RoleController_AddPost_ReturnsRedirectToRouteResult() { RoleController roleController = GetRoleController(); var userRole = new UserRole(); roleController.Add(userRole).Should().BeOfType <RedirectToRouteResult>(); }
public void RoleController_AddPost_ShouldRedirectToIndex() { RoleController roleController = GetRoleController(); var userRole = new UserRole(); var redirectToRouteResult = roleController.Add(userRole).As <RedirectToRouteResult>(); redirectToRouteResult.RouteValues["action"].Should().Be("Index"); }
public void DeleteRole() { var rc = new RoleController(true); rc.Add("testRole"); var role = rc.GetByName("testRole"); rc.Delete(role.Id); Assert.Throws <ArgumentOutOfRangeException>(() => rc.Get(role.Id)); }
public void GetRoleByNameTest() { var rc = new RoleController(true); rc.Add("testRole"); var role = rc.GetByName("testRole"); role.Should().BeOfType <Role>(); rc.Delete(role.Id); }
public void RoleController_AddPost_ShouldCallAddRoleWithPassedRole() { RoleController roleController = GetRoleController(); var userRole = new UserRole { Name = "test" }; roleController.Add(userRole); A.CallTo(() => roleService.AddRole(userRole)).MustHaveHappened(); }
public void UpdateRoleNullName() { var rc = new RoleController(true); rc.Add("testRole"); var role = rc.GetByName("testRole"); rc.Update(role.Id, null); role = rc.GetByName("testRole"); role.Should().BeOfType <Role>(); role.Name.Should().Be("testRole"); rc.Delete(role.Id); }
public UserControllerTests() { var rc = new RoleController(true); try { _roleId = rc.GetByName("testRolePatient").Id; } catch (Exception e) { rc.Add("testRolePatient"); _roleId = rc.GetByName("testRolePatient").Id; } }
public static bool RoleAddValidation(string name) { try { if (name == null || GetRoleByName(name).Name != null) { return(false); } RoleController.Add(name); return(true); } catch (Exception e) { return(false); } }
public void AddRole() { Role roleModel = new Role { Name = "role name", Description = "description role" }; Role role = controller.Add(roleModel); roleRepository.Refresh(role); Assert.AreEqual(roleModel.Name, role.Name); Assert.AreEqual(roleModel.Description, role.Description); }
public void UpdateUserTest() { var rc = new RoleController(true); rc.Add("anotherTestRole"); var role = rc.GetByName("anotherTestRole"); var uc = new UserController(true); uc.Add("testUser", "testUser", _roleId); var user = uc.GetByLogin("testUser"); uc.Update(user.Id, "updatedUser", role.Id); user.Should().BeOfType <User>(); uc.Delete(user.Id); rc.Delete(role.Id); }
public void RoleController_AddGet_ModelShouldBeAUserRole() { RoleController roleController = GetRoleController(); roleController.Add().As <PartialViewResult>().Model.Should().BeOfType <UserRole>(); }
public void RoleController_AddGet_ReturnsAPartialViewResult() { RoleController roleController = GetRoleController(); roleController.Add().Should().BeOfType <PartialViewResult>(); }
private void _btnaddpermiss_Click(object sender, RoutedEventArgs e) { try { if (_btnaddpermiss.Content.Equals("Add new")) { _btnaddpermiss.Content = "Ok"; _btncanceladdpermiss.IsEnabled = true; _btneditpermiss.IsEnabled = false; _btndeletepermiss.IsEnabled = false; _btnloadpermiss.IsEnabled = false; gridPerMiss.IsEnabled = false; _txtrolename.Clear(); _checkAddAll.IsChecked = _checkAddDocGia.IsChecked = _checkAddSach.IsChecked = _checkAddSM.IsChecked = _checkAdduser.IsChecked = _checkViewAll.IsChecked = _checkViewDocGia.IsChecked = _checkViewSach.IsChecked = _checkViewSM.IsChecked = _checkViewuser.IsChecked = _checkViewThongKe.IsChecked = _checkEditAll.IsChecked = _checkEditDocGia.IsChecked = _checkEditSach.IsChecked = _checkEditSM.IsChecked = _checkEdituser.IsChecked = _checkDeleteAll.IsChecked = _checkDeleteDocGia.IsChecked = _checkDeleteSach.IsChecked = _checkDeleteSM.IsChecked = _checkDeleteuser.IsChecked = null; return; } if (String.IsNullOrWhiteSpace(_txtrolename.Text)) { MessageBox.Show("Role Name không được để trống.", "Thêm mới Role", MessageBoxButton.OK, MessageBoxImage.Warning); return; } Role _role = new Role(); _role.RoleName = _txtrolename.Text; _role.AddAll = _checkAddAll.IsChecked; _role.AddDocGia = _checkAddDocGia.IsChecked; _role.AddSach = _checkAddSach.IsChecked; _role.AddSachMuon = _checkAddSM.IsChecked; _role.AddUser = _checkAdduser.IsChecked; _role.ViewAll = _checkViewAll.IsChecked; _role.ViewDocGia = _checkViewDocGia.IsChecked; _role.ViewSach = true; _role.ViewSachMuon = _checkViewSM.IsChecked; _role.ViewUser = _checkViewuser.IsChecked; _role.ViewThongKe = _checkViewThongKe.IsChecked; _role.EditAll = _checkEditAll.IsChecked; _role.EditDocGia = _checkEditDocGia.IsChecked; _role.EditSach = _checkEditSach.IsChecked; _role.EditSachMuon = _checkEditSM.IsChecked; _role.EditUser = _checkEdituser.IsChecked; _role.DeleteAll = _checkDeleteAll.IsChecked; _role.DeleteDocGia = _checkDeleteDocGia.IsChecked; _role.DeleteSach = _checkDeleteSach.IsChecked; _role.DeleteSachMuon = _checkDeleteSM.IsChecked; _role.DeleteUser = _checkDeleteuser.IsChecked; if (rolecontroll.Add(_role)) { MessageBox.Show( "Thêm mới thành công", "Thêm mới role", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show( "Thêm mới thất bại", "Thêm mới role", MessageBoxButton.OK, MessageBoxImage.Error); } _btnaddpermiss.Content = "Add new"; _btncanceladdpermiss.IsEnabled = false; _btneditpermiss.IsEnabled = true; _btndeletepermiss.IsEnabled = true; _btnloadpermiss.IsEnabled = true; gridPerMiss.IsEnabled = true; LoadRoleTable(); } catch { } }