Exemple #1
0
        public AdminRoleRepositoryShould()
        {
            // Given
            var logger = new Mock <ILogger <AdminRoleRepository> >();

            _adminRoleRepository = new AdminRoleRepository(logger.Object);
        }
Exemple #2
0
        public void LoadData()
        {
            AdminRoleRepository repo = UnityConfig.Container.Resolve <AdminRoleRepository>();
            List <GradeUrlItem> data = repo.GetMenu();

            this.gradeUrl = data.GroupBy(g => g.Grade_Code)
                            .ToDictionary(s => s.Key, s => s.ToList());
        }
Exemple #3
0
        private static void SetAdminUserPermissions(ref UserPrincipal serializeModel)
        {
            IDatabaseFactory     databaseFactory     = new DatabaseFactory();
            IAdminUserRepository adminUserRepository = new AdminUserRepository(databaseFactory);
            IAdminRoleRepository adminRoleRepository = new AdminRoleRepository(databaseFactory);
            IUnitOfWork          unitOfWork          = new UnitOfWork(databaseFactory);

            IAdminUserService adminUserService = new AdminUserService(adminUserRepository, adminRoleRepository, unitOfWork);

            serializeModel.Permissions = adminUserService.GetPermissions(serializeModel.UserId);
            serializeModel.Roles       = adminUserService.GetRoles(serializeModel.UserId);
        }
Exemple #4
0
        public async void Return3RowsGivenGetAll()
        {
            // When
            var glownyShopContext       = new GlownyShopContext(_options, _dbLogger.Object);
            var repoLogger              = new Mock <ILogger <AdminRoleRepository> >();
            var _adminRoleRepositoryAll = new AdminRoleRepository(glownyShopContext, repoLogger.Object);
            var adminRoles              = await _adminRoleRepositoryAll.GetAll();

            // Then
            Assert.NotNull(adminRoles);
            Assert.Equal(3, adminRoles.Count);

            //CleanUp
            var saved = await _adminRoleRepositoryAll.SaveChangesAsync();
        }
Exemple #5
0
        public AdminRoleRepositoryShould()
        {
            // Given
            _dbLogger = new Mock <ILogger <GlownyShopContext> >();
            // https://docs.microsoft.com/en-us/ef/core/miscellaneous/testing/in-memory
            _options = new DbContextOptionsBuilder <GlownyShopContext>()
                       .UseInMemoryDatabase(databaseName: "GlownyShop_AdminRole")
                       .Options;
            using (var context = new GlownyShopContext(_options, _dbLogger.Object))
            {
                context.EnsureSeedData();
            }
            var glownyShopContext = new GlownyShopContext(_options, _dbLogger.Object);
            var repoLogger        = new Mock <ILogger <AdminRoleRepository> >();

            _adminRoleRepository = new AdminRoleRepository(glownyShopContext, repoLogger.Object);
        }
Exemple #6
0
 public AdminRoleManager()
 {
     this.roleRepository=new AdminRoleRepository();
 }