public void Role_Create_Check_Should_Succeed() { var roleModel = RoleTestData.GetUserRoleModel(); var role = RoleTestData.GetNullRole(); roleRepository.Setup(r => r.GetById(a => a.Name == roleModel.Name)).Returns(role); roleRepository.Setup(r => r.GetById(a => a.Code == roleModel.Code)).Returns(role); roleBusinessRules.CreateCheck(roleModel, roleRepository.Object); }
public void Role_Add_Null_Role_Should_Throw_Exception() { using (var context = new PayrollContext(IntergrationTestsSetup.ContextOptions)) { var unitOfWork = new UnitOfWork(context); var role = RoleTestData.GetNullRole(); unitOfWork.Role.Insert(null); unitOfWork.Save(); } }
public void Role_Update_Check_Should_Throw_Exception_Role_Code_Already_Exists() { var roleModel = RoleTestData.GetUserRoleModel(); var role = RoleTestData.GetUserRole(); roleRepository.Setup(r => r.GetById(It.Is <Expression <Func <Data.Role, bool> > >(e => AreEqual <Data.Role, bool>(e, "roleModel.Id")))).Returns(role); roleRepository.Setup(r => r.GetById(It.Is <Expression <Func <Data.Role, bool> > >(e => AreEqual <Data.Role, bool>(e, "roleModel.Code")))).Returns(role); roleRepository.Setup(r => r.GetById(It.Is <Expression <Func <Data.Role, bool> > >(e => AreEqual <Data.Role, bool>(e, "roleModel.Name")))).Returns(RoleTestData.GetNullRole()); roleBusinessRules.UpdateCheck(roleModel, roleRepository.Object); }
public void Role_Create_Check_Should_Fail_If_Role_Code_Already_Exist() { var roleModel = RoleTestData.GetUserRoleModel(); var role = RoleTestData.GetUserRole(); roleRepository.Setup(r => r.GetById(It.Is <Expression <Func <Data.Role, bool> > >(e => AreEqual <Data.Role, bool>(e, "roleModel.Name")))).Returns(RoleTestData.GetNullRole()); roleRepository.Setup(r => r.GetById(It.Is <Expression <Func <Data.Role, bool> > >(e => AreEqual <Data.Role, bool>(e, "roleModel.Code")))).Returns(role); roleBusinessRules.CreateCheck(roleModel, roleRepository.Object); roleRepository.Verify(r => r.GetById(It.IsAny <Expression <Func <Data.Role, bool> > >()), Times.Exactly(2)); }