public void Role_Add_Empty_Role_Should_Throw_Exception() { using (var context = new PayrollContext(IntergrationTestsSetup.ContextOptions)) { var unitOfWork = new UnitOfWork(context); var role = RoleTestData.GetEmptyRole(); unitOfWork.Role.Insert(null); unitOfWork.Save(); } }
public void Should_Create_Role() { // Arrange unitOfWork.Setup(x => x.Save()).Verifiable(); unitOfWork.Setup(x => x.Role.Insert(It.IsAny <Data.Role>())).Verifiable(); roleBusinessRules.Setup(x => x.CreateCheck(It.IsAny <RoleModel>(), It.IsAny <RoleRepository>())).Verifiable(); roleBuilder.Setup(x => x.Build(It.IsAny <RoleModel>())).Returns(RoleTestData.GetEmptyRole()); roleBuilder.Setup(x => x.BuildModel(It.IsAny <Data.Role>())).Returns(new RoleModel()); unitOfWork.Setup(x => x.Role.GetById(It.IsAny <Expression <Func <Data.Role, bool> > >())).Returns(RoleTestData.GetUserRole()); // Act var result = roleService.Create(RoleTestData.GetUserRoleModel()); // Assert roleBusinessRules.Verify(x => x.CreateCheck(It.IsAny <RoleModel>(), It.IsAny <RoleRepository>()), Times.Once); roleBuilder.Verify(x => x.Build(It.IsAny <RoleModel>()), Times.Once); unitOfWork.Verify(x => x.Role.GetById(It.IsAny <Expression <Func <Data.Role, bool> > >()), Times.Once); roleBuilder.Verify(x => x.BuildModel(It.IsAny <Data.Role>()), Times.Once); }