public void Create(User user) { var dbEntity = _mapper.Map <UserDbEntity>(user); _entities.Add(dbEntity); _context.SaveChanges(); }
public void Create(Page page) { var pageDbEntity = _mapper.Map <PageDbEntity>(page); _pages.Add(pageDbEntity); _context.SaveChanges(); }
public void Create(Menu menu) { var menuDbEntity = _mapper.Map <MenuDbEntity>(menu); _menus.Add(menuDbEntity); _context.SaveChanges(); }
public void Create(App app) { var dbEntity = _mapper.Map <AppDbEntity>(app); _entities.Add(dbEntity); _context.SaveChanges(); }
public void SetUp() { var optionsBuilder = new DbContextOptionsBuilder <WeapsyDbContext>(); optionsBuilder.UseInMemoryDatabase(); _dbContext = new WeapsyDbContext(optionsBuilder.Options); _siteId = Guid.NewGuid(); _languageId1 = Guid.NewGuid(); _languageId2 = Guid.NewGuid(); _dbContext.Set <LanguageDbEntity>().AddRange( new LanguageDbEntity { SiteId = _siteId, Id = _languageId1, Name = "Language Name 1", CultureName = "ab1", Url = "ab1", Status = LanguageStatus.Active }, new LanguageDbEntity { SiteId = _siteId, Id = _languageId2, Name = "Language Name 2", CultureName = "ab2", Url = "ab2", Status = LanguageStatus.Hidden }, new LanguageDbEntity { Status = LanguageStatus.Deleted } ); _dbContext.SaveChanges(); var mapperMock = new Mock <IMapper>(); mapperMock.Setup(x => x.Map <LanguageDbEntity>(It.IsAny <Language>())).Returns(new LanguageDbEntity()); mapperMock.Setup(x => x.Map <Language>(It.IsAny <LanguageDbEntity>())).Returns(new Language()); mapperMock.Setup(x => x.Map <ICollection <Language> >(It.IsAny <ICollection <LanguageDbEntity> >())).Returns(new List <Language> { LanguageFactory.Language(_siteId, _languageId1, "Name", "CultureName", "Url"), LanguageFactory.Language(_siteId, _languageId2, "Name", "CultureName", "Url") }); _sut = new LanguageRepository(_dbContext, mapperMock.Object); }
public void SetUp() { var optionsBuilder = new DbContextOptionsBuilder <WeapsyDbContext>(); optionsBuilder.UseInMemoryDatabase(); var dbContext = new WeapsyDbContext(optionsBuilder.Options); _siteId = Guid.NewGuid(); _moduleId1 = Guid.NewGuid(); _moduleId2 = Guid.NewGuid(); _moduleTypeId1 = Guid.NewGuid(); _moduleTypeId2 = Guid.NewGuid(); dbContext.Set <ModuleDbEntity>().AddRange( new ModuleDbEntity { SiteId = _siteId, Id = _moduleId1, ModuleTypeId = _moduleTypeId1, Title = "Title 1", Status = ModuleStatus.Active }, new ModuleDbEntity { SiteId = _siteId, Id = _moduleId2, ModuleTypeId = _moduleTypeId2, Title = "Title 2", Status = ModuleStatus.Active }, new ModuleDbEntity { Status = ModuleStatus.Deleted } ); dbContext.SaveChanges(); var mapperMock = new Mock <AutoMapper.IMapper>(); mapperMock.Setup(x => x.Map <ModuleDbEntity>(It.IsAny <Module>())).Returns(new ModuleDbEntity()); mapperMock.Setup(x => x.Map <Module>(It.IsAny <ModuleDbEntity>())).Returns(new Module()); mapperMock.Setup(x => x.Map <ICollection <Module> >(It.IsAny <ICollection <ModuleDbEntity> >())).Returns(new List <Module> { ModuleFactory.Module(_siteId, _moduleTypeId1, _moduleId1, "Title"), ModuleFactory.Module(_siteId, _moduleTypeId2, _moduleId2, "Title") }); _sut = new ModuleRepository(dbContext, mapperMock.Object); }
public void SetUp() { var optionsBuilder = new DbContextOptionsBuilder <WeapsyDbContext>(); optionsBuilder.UseInMemoryDatabase(); _dbContext = new WeapsyDbContext(optionsBuilder.Options); _themeId1 = Guid.NewGuid(); _themeId2 = Guid.NewGuid(); _dbContext.Set <ThemeDbEntity>().AddRange ( new ThemeDbEntity { Id = _themeId1, Name = "Name 1", Description = "Description 1", Folder = "Folder 1", Status = ThemeStatus.Active }, new ThemeDbEntity { Id = _themeId2, Name = "Name 2", Description = "Description 2", Folder = "Folder 2", Status = ThemeStatus.Active }, new ThemeDbEntity { Status = ThemeStatus.Deleted } ); _dbContext.SaveChanges(); var mapperMock = new Mock <AutoMapper.IMapper>(); mapperMock.Setup(x => x.Map <ThemeDbEntity>(It.IsAny <Theme>())).Returns(new ThemeDbEntity()); mapperMock.Setup(x => x.Map <Theme>(It.IsAny <ThemeDbEntity>())).Returns(new Theme()); mapperMock.Setup(x => x.Map <ICollection <Theme> >(It.IsAny <ICollection <ThemeDbEntity> >())).Returns(new List <Theme> { ThemeFactory.Theme(_themeId1, "Name", "Description", "Folder"), ThemeFactory.Theme(_themeId2, "Name", "Description", "Folder") }); _sut = new ThemeRepository(_dbContext, mapperMock.Object); }
public void SetUp() { var optionsBuilder = new DbContextOptionsBuilder <WeapsyDbContext>(); optionsBuilder.UseInMemoryDatabase(); var dbContext = new WeapsyDbContext(optionsBuilder.Options); _siteId1 = Guid.NewGuid(); _siteId2 = Guid.NewGuid(); dbContext.Set <SiteDbEntity>().AddRange( new SiteDbEntity { Id = _siteId1, Name = "Name 1", Title = "Title 1", Url = "Url 1", Status = SiteStatus.Active }, new SiteDbEntity { Id = _siteId2, Name = "Name 2", Title = "Title 2", Url = "Url 2", Status = SiteStatus.Active }, new SiteDbEntity { Status = SiteStatus.Deleted } ); dbContext.SaveChanges(); var mapperMock = new Mock <AutoMapper.IMapper>(); mapperMock.Setup(x => x.Map <SiteDbEntity>(It.IsAny <Site>())).Returns(new SiteDbEntity()); mapperMock.Setup(x => x.Map <Site>(It.IsAny <SiteDbEntity>())).Returns(new Site()); mapperMock.Setup(x => x.Map <IList <Site> >(It.IsAny <IList <SiteDbEntity> >())).Returns(new List <Site> { SiteFactory.Site(_siteId1, "Name"), SiteFactory.Site(_siteId2, "Name") }); _sut = new SiteRepository(dbContext, mapperMock.Object); }
public void SetUp() { var optionsBuilder = new DbContextOptionsBuilder <WeapsyDbContext>(); optionsBuilder.UseInMemoryDatabase(); var dbContext = new WeapsyDbContext(optionsBuilder.Options); _moduleTypeId1 = Guid.NewGuid(); _moduleTypeId2 = Guid.NewGuid(); dbContext.Set <ModuleTypeDbEntity>().AddRange( new ModuleTypeDbEntity { Id = _moduleTypeId1, Name = "Name 1", Title = "Title 1", Description = "Description 1", Status = ModuleTypeStatus.Active }, new ModuleTypeDbEntity { Id = _moduleTypeId2, Name = "Name 2", Title = "Title 2", Description = "Description 2", Status = ModuleTypeStatus.Active }, new ModuleTypeDbEntity { Status = ModuleTypeStatus.Deleted } ); dbContext.SaveChanges(); var mapperMock = new Moq.Mock <AutoMapper.IMapper>(); mapperMock.Setup(x => x.Map <ModuleTypeDbEntity>(Moq.It.IsAny <ModuleType>())).Returns(new ModuleTypeDbEntity()); mapperMock.Setup(x => x.Map <ModuleType>(Moq.It.IsAny <ModuleTypeDbEntity>())).Returns(new ModuleType()); _sut = new ModuleTypeRepository(dbContext, mapperMock.Object); }
public void Setup() { _contextOptions = DbContextShared.CreateContextOptions(); using (var context = new WeapsyDbContext(_contextOptions)) { _siteId = Guid.NewGuid(); context.Sites.AddRange( new Site { Id = _siteId, Name = "Site 1", Status = SiteStatus.Active } ); context.SaveChanges(); } }
public void Setup() { _contextOptions = DbContextShared.CreateContextOptions(); using (var context = new WeapsyDbContext(_contextOptions)) { _moduleTypeId = Guid.NewGuid(); context.ModuleTypes.AddRange( new ModuleType { Id = _moduleTypeId, Name = "ModuleType 1", Status = ModuleTypeStatus.Active } ); context.SaveChanges(); } }
public void Setup() { _contextOptions = DbContextShared.CreateContextOptions(); using (var context = new WeapsyDbContext(_contextOptions)) { _siteId = Guid.NewGuid(); _emailAccountId = Guid.NewGuid(); context.EmailAccounts.AddRange( new EmailAccount { SiteId = _siteId, Id = _emailAccountId, Status = EmailAccountStatus.Active } ); context.SaveChanges(); } }
public void SetUp() { _contextOptions = DbContextShared.CreateContextOptions(); using (var context = new WeapsyDbContext(_contextOptions)) { _siteId = Guid.NewGuid(); _languageId1 = Guid.NewGuid(); _languageId2 = Guid.NewGuid(); _deletedLanguageId = Guid.NewGuid(); context.Languages.AddRange( new LanguageDbEntity { SiteId = _siteId, Id = _languageId1, Name = "Language Name 1", CultureName = "ab1", Url = "ab1", Status = LanguageStatus.Active }, new LanguageDbEntity { SiteId = _siteId, Id = _languageId2, Name = "Language Name 2", CultureName = "ab2", Url = "ab2", Status = LanguageStatus.Hidden }, new LanguageDbEntity { Id = _deletedLanguageId, Status = LanguageStatus.Deleted } ); context.SaveChanges(); } }
public void SetUp() { _contextOptions = DbContextShared.CreateContextOptions(); using (var context = new WeapsyDbContext(_contextOptions)) { _siteId = Guid.NewGuid(); _moduleId1 = Guid.NewGuid(); _moduleId2 = Guid.NewGuid(); _moduleTypeId1 = Guid.NewGuid(); _moduleTypeId2 = Guid.NewGuid(); _deletedModuleId = Guid.NewGuid(); context.Set <ModuleDbEntity>().AddRange( new ModuleDbEntity { SiteId = _siteId, Id = _moduleId1, ModuleTypeId = _moduleTypeId1, Title = "Title 1", Status = ModuleStatus.Active }, new ModuleDbEntity { SiteId = _siteId, Id = _moduleId2, ModuleTypeId = _moduleTypeId2, Title = "Title 2", Status = ModuleStatus.Active }, new ModuleDbEntity { Id = _deletedModuleId, Status = ModuleStatus.Deleted } ); context.SaveChanges(); } }
public void Setup() { _contextOptions = DbContextShared.CreateContextOptions(); using (var context = new WeapsyDbContext(_contextOptions)) { _siteId = Guid.NewGuid(); _menuId = Guid.NewGuid(); context.Menus.AddRange( new Menu { SiteId = _siteId, Id = _menuId, Name = "Menu Name 1", Status = MenuStatus.Active } ); context.SaveChanges(); } }
public void SetUp() { _contextOptions = Shared.CreateContextOptions(); using (var context = new WeapsyDbContext(_contextOptions)) { _themeId1 = Guid.NewGuid(); _themeId2 = Guid.NewGuid(); _deletedThemeId = Guid.NewGuid(); context.Set <ThemeDbEntity>().AddRange ( new ThemeDbEntity { Id = _themeId1, Name = "Name 1", Description = "Description 1", Folder = "Folder 1", Status = ThemeStatus.Active }, new ThemeDbEntity { Id = _themeId2, Name = "Name 2", Description = "Description 2", Folder = "Folder 2", Status = ThemeStatus.Active }, new ThemeDbEntity { Id = _deletedThemeId, Status = ThemeStatus.Deleted } ); context.SaveChanges(); } }
public void SetUp() { _contextOptions = DbContextShared.CreateContextOptions(); using (var context = new WeapsyDbContext(_contextOptions)) { _siteId1 = Guid.NewGuid(); _siteId2 = Guid.NewGuid(); _deletedSiteId = Guid.NewGuid(); context.Sites.AddRange( new SiteDbEntity { Id = _siteId1, Name = "Name 1", Title = "Title 1", Url = "Url 1", Status = SiteStatus.Active }, new SiteDbEntity { Id = _siteId2, Name = "Name 2", Title = "Title 2", Url = "Url 2", Status = SiteStatus.Active }, new SiteDbEntity { Id = _deletedSiteId, Status = SiteStatus.Deleted } ); context.SaveChanges(); } }
public void SetUp() { _contextOptions = DbContextShared.CreateContextOptions(); using (var context = new WeapsyDbContext(_contextOptions)) { _moduleTypeId1 = Guid.NewGuid(); _moduleTypeId2 = Guid.NewGuid(); _deletedModuleTypeId = Guid.NewGuid(); context.ModuleTypes.AddRange( new ModuleTypeDbEntity { Id = _moduleTypeId1, Name = "Name 1", Title = "Title 1", Description = "Description 1", Status = ModuleTypeStatus.Active }, new ModuleTypeDbEntity { Id = _moduleTypeId2, Name = "Name 2", Title = "Title 2", Description = "Description 2", Status = ModuleTypeStatus.Active }, new ModuleTypeDbEntity { Id = _deletedModuleTypeId, Status = ModuleTypeStatus.Deleted } ); context.SaveChanges(); } }
public void Setup() { _contextOptions = DbContextShared.CreateContextOptions(); using (var context = new WeapsyDbContext(_contextOptions)) { _siteId = Guid.NewGuid(); _languageId = Guid.NewGuid(); context.Languages.AddRange( new Language { SiteId = _siteId, Id = _languageId, Name = "Language Name 1", CultureName = "ab1", Url = "ab1", Status = LanguageStatus.Active } ); context.SaveChanges(); } }
public void Create(Site site) { _sites.Add(_mapper.Map <SiteDbEntity>(site)); _context.SaveChanges(); }
public void Create(Theme theme) { _entities.Add(_mapper.Map <ThemeDbEntity>(theme)); _context.SaveChanges(); }
public void SetUp() { var optionsBuilder = new DbContextOptionsBuilder <WeapsyDbContext>(); optionsBuilder.UseInMemoryDatabase(); var dbContext = new WeapsyDbContext(optionsBuilder.Options); _siteId = Guid.NewGuid(); _pageId1 = Guid.NewGuid(); _pageId2 = Guid.NewGuid(); _moduleId1 = Guid.NewGuid(); _pageModuleId1 = Guid.NewGuid(); _languageId1 = Guid.NewGuid(); dbContext.Set <PageDbEntity>().AddRange( new PageDbEntity { SiteId = _siteId, Id = _pageId1, Name = "Name 1", Url = "Url 1", Status = PageStatus.Active, PageModules = new List <PageModuleDbEntity> { new PageModuleDbEntity { PageId = _pageId1, ModuleId = _moduleId1, Id = _pageModuleId1, Title = "Title 1", Status = PageModuleStatus.Active, PageModuleLocalisations = new List <PageModuleLocalisationDbEntity> { new PageModuleLocalisationDbEntity { PageModuleId = _pageModuleId1, LanguageId = _languageId1 }, new PageModuleLocalisationDbEntity { PageModuleId = _pageModuleId1, LanguageId = Guid.NewGuid() } } }, new PageModuleDbEntity { PageId = _pageId1, ModuleId = Guid.NewGuid(), Id = Guid.NewGuid(), Title = "Title 2", Status = PageModuleStatus.Deleted } } }, new PageDbEntity { SiteId = _siteId, Id = _pageId2, Name = "Name 2", Url = "Url 2", Status = PageStatus.Active }, new PageDbEntity { Status = PageStatus.Deleted } ); dbContext.SaveChanges(); var mapperMock = new Moq.Mock <AutoMapper.IMapper>(); mapperMock.Setup(x => x.Map <PageDbEntity>(Moq.It.IsAny <Page>())).Returns(new PageDbEntity()); mapperMock.Setup(x => x.Map <Page>(Moq.It.IsAny <PageDbEntity>())).Returns(new Page()); _sut = new PageRepository(dbContext, mapperMock.Object); }
public void Create(Module module) { _entities.Add(_mapper.Map <ModuleDbEntity>(module)); _context.SaveChanges(); }
public void SetUp() { var optionsBuilder = new DbContextOptionsBuilder <WeapsyDbContext>(); optionsBuilder.UseInMemoryDatabase(); var dbContext = new WeapsyDbContext(optionsBuilder.Options); _siteId = Guid.NewGuid(); _menuId1 = Guid.NewGuid(); _menuId2 = Guid.NewGuid(); _menuItemId1 = Guid.NewGuid(); _menuItemId2 = Guid.NewGuid(); _language1 = Guid.NewGuid(); dbContext.Set <MenuDbEntity>().AddRange( new MenuDbEntity { SiteId = _siteId, Id = _menuId1, Name = "Menu 1", Status = MenuStatus.Active, MenuItems = new List <MenuItemDbEntity> { new MenuItemDbEntity { MenuId = _menuId1, Id = _menuItemId1, Text = "Menu Item 1", Status = MenuItemStatus.Active, MenuItemLocalisations = new List <MenuItemLocalisationDbEntity> { new MenuItemLocalisationDbEntity { MenuItemId = _menuItemId1, LanguageId = _language1, Text = "Menu Item 1 Localisation 1" }, new MenuItemLocalisationDbEntity { MenuItemId = _menuItemId1, LanguageId = Guid.NewGuid(), Text = "Menu Item 1 Localisation 2" } } }, new MenuItemDbEntity { MenuId = _menuId1, Id = _menuItemId2, Text = "Menu Item 2", Status = MenuItemStatus.Deleted } } }, new MenuDbEntity { SiteId = _siteId, Id = _menuId2, Name = "Menu 2", Status = MenuStatus.Active }, new MenuDbEntity { Status = MenuStatus.Deleted } ); dbContext.SaveChanges(); var mapperMock = new Moq.Mock <AutoMapper.IMapper>(); mapperMock.Setup(x => x.Map <MenuDbEntity>(Moq.It.IsAny <Menu>())).Returns(new MenuDbEntity()); mapperMock.Setup(x => x.Map <Menu>(Moq.It.IsAny <MenuDbEntity>())).Returns(new Menu()); _sut = new MenuRepository(dbContext, mapperMock.Object); }
public void Create(Language language) { _entities.Add(_mapper.Map <LanguageDbEntity>(language)); _context.SaveChanges(); }
public void SetUp() { _contextOptions = DbContextShared.CreateContextOptions(); using (var context = new WeapsyDbContext(_contextOptions)) { _siteId = Guid.NewGuid(); _pageId1 = Guid.NewGuid(); _pageId2 = Guid.NewGuid(); _moduleId1 = Guid.NewGuid(); _pageModuleId1 = Guid.NewGuid(); _languageId1 = Guid.NewGuid(); _deletedPageId = Guid.NewGuid(); context.Pages.AddRange( new PageDbEntity { SiteId = _siteId, Id = _pageId1, Name = "Name 1", Url = "Url 1", Status = PageStatus.Active, PageModules = new List <PageModuleDbEntity> { new PageModuleDbEntity { PageId = _pageId1, ModuleId = _moduleId1, Id = _pageModuleId1, Title = "Title 1", Status = PageModuleStatus.Active, PageModuleLocalisations = new List <PageModuleLocalisationDbEntity> { new PageModuleLocalisationDbEntity { PageModuleId = _pageModuleId1, LanguageId = _languageId1 }, new PageModuleLocalisationDbEntity { PageModuleId = _pageModuleId1, LanguageId = Guid.NewGuid() } } }, new PageModuleDbEntity { PageId = _pageId1, ModuleId = Guid.NewGuid(), Id = Guid.NewGuid(), Title = "Title 2", Status = PageModuleStatus.Deleted } }, PageLocalisations = new List <PageLocalisation> { new PageLocalisation { PageId = _pageId1, LanguageId = _languageId1, Url = "localised-url-1" } } }, new PageDbEntity { SiteId = _siteId, Id = _pageId2, Name = "Name 2", Url = "Url 2", Status = PageStatus.Active }, new PageDbEntity { Id = _deletedPageId, Status = PageStatus.Deleted } ); context.SaveChanges(); } }
public void SetUp() { _contextOptions = DbContextShared.CreateContextOptions(); using (var context = new WeapsyDbContext(_contextOptions)) { _siteId = Guid.NewGuid(); _menuId1 = Guid.NewGuid(); _menuId2 = Guid.NewGuid(); _menuItemId1 = Guid.NewGuid(); _menuItemId2 = Guid.NewGuid(); _language1 = Guid.NewGuid(); _deletedMenuId = Guid.NewGuid(); context.Menus.AddRange( new MenuDbEntity { SiteId = _siteId, Id = _menuId1, Name = "Menu 1", Status = MenuStatus.Active, MenuItems = new List <MenuItemDbEntity> { new MenuItemDbEntity { MenuId = _menuId1, Id = _menuItemId1, Text = "Menu Item 1", Status = MenuItemStatus.Active, MenuItemLocalisations = new List <MenuItemLocalisationDbEntity> { new MenuItemLocalisationDbEntity { MenuItemId = _menuItemId1, LanguageId = _language1, Text = "Menu Item 1 Localisation 1" }, new MenuItemLocalisationDbEntity { MenuItemId = _menuItemId1, LanguageId = Guid.NewGuid(), Text = "Menu Item 1 Localisation 2" } } }, new MenuItemDbEntity { MenuId = _menuId1, Id = _menuItemId2, Text = "Menu Item 2", Status = MenuItemStatus.Deleted } } }, new MenuDbEntity { SiteId = _siteId, Id = _menuId2, Name = "Menu 2", Status = MenuStatus.Active }, new MenuDbEntity { Id = _deletedMenuId, Status = MenuStatus.Deleted } ); context.SaveChanges(); } }