Example #1
0
        public UnitOfWork(ApplicationDbContext dbContext)
        {
            this.dbContext = dbContext;

            DocumentsService             = new DocumentsService(dbContext);
            DocumentsStatesService       = new DocumentsStatesService(dbContext);
            DocumentsTemplateItemService = new DocumentsTemplateItemService(dbContext);
            DocumentsTemplateService     = new DocumentsTemplateService(dbContext);
            DocumentTaskTemplatesService = new DocumentTaskTemplatesService(dbContext);
            DocumentTasksService         = new DocumentTasksService(dbContext);
            LogsService       = new LogsService(dbContext);
            RolesService      = new RolesService(dbContext);
            TagsService       = new TagsService(dbContext);
            UsersService      = new UsersService(dbContext);
            UserGroupsService = new UserGroupsService(dbContext);
        }
Example #2
0
        public async Task Can_Return_All_User_Groups()
        {
            var dbContextOptions = CreateNewContextOptions();

            using (var context = new ApplicationDbContext(dbContextOptions))
            {
                context.UserGroups.AddRange(new UserGroup(), new UserGroup());
                await context.SaveChangesAsync();
            }

            using (var context = new ApplicationDbContext(dbContextOptions))
            {
                var service = new UserGroupsService(context);
                var result  = await service.GetAll();

                Assert.Equal(2, result.Count);
            }
        }
Example #3
0
        public async Task Can_Add_User_Group()
        {
            var dbContextOptions = CreateNewContextOptions();

            using (var context = new ApplicationDbContext(dbContextOptions))
            {
                var service = new UserGroupsService(context);
                service.Add(UserGroups.STUDENT);

                await context.SaveChangesAsync();
            }

            using (var context = new ApplicationDbContext(dbContextOptions))
            {
                var userGroups = await context.UserGroups.ToListAsync();

                Assert.Equal(1, userGroups.Count);
                Assert.Equal(UserGroups.STUDENT, userGroups.First().Name);
            }
        }