public void Should_update_menu() { const string newMenuName = "New Menu 1"; const string newMenuItemText = "New Menu Item 1"; const string newMenuItemLocalisationText = "New Menu Item 1 Localisation 1"; var menuToUpdate = MenuFactory.Menu(_siteId, _menuId1, newMenuName, newMenuItemText, newMenuItemLocalisationText, _menuItemId1, _language1); using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new MenuRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Update(menuToUpdate); } using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new MenuRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var updatedMenu = repository.GetById(_siteId, _menuId1); var updatedMenuItem = updatedMenu.MenuItems.FirstOrDefault(); var updatedMenuItemLocalisation = updatedMenuItem.MenuItemLocalisations.FirstOrDefault(); Assert.AreEqual(newMenuName, updatedMenu.Name); Assert.AreEqual(newMenuItemText, updatedMenuItem.Text); Assert.AreEqual(newMenuItemLocalisationText, updatedMenuItemLocalisation.Text); } }
public static IDbContextFactory CreateNewContextFactory(MSSQLDbContext context) { var dbContextFactoryMock = new Mock <IDbContextFactory>(); dbContextFactoryMock.Setup(x => x.Create()).Returns(context); return(dbContextFactoryMock.Object); }
public void Should_update_languages() { var newLanguageName1 = "New Language Name 1"; var newLanguageName2 = "New Language Name 2"; var languageToUpdate1 = LanguageFactory.Language(_siteId, _languageId1, newLanguageName1, "ab1", "ab1"); var languageToUpdate2 = LanguageFactory.Language(_siteId, _languageId2, newLanguageName2, "ab2", "ab2"); using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new LanguageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Update(new List <Language> { languageToUpdate1, languageToUpdate2 }); } using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new LanguageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var updatedLanguage1 = repository.GetById(_siteId, _languageId1); Assert.AreEqual(newLanguageName1, updatedLanguage1.Name); } using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new LanguageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var updatedLanguage2 = repository.GetById(_siteId, _languageId2); Assert.AreEqual(newLanguageName2, updatedLanguage2.Name); } }
public static void Main(string[] args) { MSSQLDbContext db = new MSSQLDbContext(); db.Database.EnsureCreated(); CreateHostBuilder(args).Build().Run(); }
public void Should_return_model_for_admin() { using (var context = new MSSQLDbContext(_contextOptions)) { var facade = new LanguageFacade(DbContextShared.CreateNewContextFactory(context), new Mock <ICacheManager>().Object, Shared.CreateNewMapper()); var model = facade.GetForAdminAsync(_siteId, _languageId); Assert.NotNull(model); } }
public void Should_return_model() { using (var context = new MSSQLDbContext(_contextOptions)) { var facade = new EmailAccountFacade(DbContextShared.CreateNewContextFactory(context), new Mock <ICacheManager>().Object, Shared.CreateNewMapper()); var model = facade.Get(_siteId, _emailAccountId); Assert.NotNull(model); } }
public void Should_return_page_id_by_name() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new PageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var pageId = repository.GetPageIdByName(_siteId, "Name 2"); Assert.AreEqual(_pageId2, pageId); } }
public void Should_return_theme_by_folder() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new ThemeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var theme = repository.GetByFolder("Folder 1"); Assert.NotNull(theme); } }
public void Should_return_themes_count() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new ThemeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var count = repository.GetThemesCount(); Assert.AreEqual(2, count); } }
public void Should_return_count_by_module_type_id() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new ModuleRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var count = repository.GetCountByModuleTypeId(_moduleTypeId1); Assert.AreEqual(1, count); } }
public void Should_return_module_by_id() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new ModuleRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var module = repository.GetById(_moduleId1); Assert.NotNull(module); } }
public void Should_return_menu_by_name_with_no_deleted_menu_items() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new MenuRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var menu = repository.GetByName(_siteId, "Menu 1"); Assert.AreEqual(0, menu.MenuItems.Where(x => x.Status == MenuItemStatus.Deleted).Count()); } }
public void Should_return_menu_by_name() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new MenuRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var menu = repository.GetByName(_siteId, "Menu 1"); Assert.NotNull(menu); } }
public void Should_return_null_if_menu_is_deleted() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new MenuRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var menu = repository.GetById(_deletedMenuId); Assert.Null(menu); } }
public void Should_return_page_id_by_localised_slug() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new PageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var pageId = repository.GetPageIdByLocalisedSlug(_siteId, "localised-url-1"); Assert.AreNotEqual(Guid.Empty, pageId); } }
public void Should_return_module_type_by_name() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new ModuleTypeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var moduleType = repository.GetByName("Name 1"); Assert.NotNull(moduleType); } }
public void Should_return_site_by_url() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var site = repository.GetByUrl("Url 1"); Assert.NotNull(site); } }
public void Should_return_null_if_site_is_deleted() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var site = repository.GetById(_deletedSiteId); Assert.Null(site); } }
public void Should_return_page_by_id_with_no_deleted_page_modules() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new PageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var page = repository.GetById(_siteId, _pageId1); Assert.AreEqual(0, page.PageModules.Count(x => x.Status == PageModuleStatus.Deleted)); } }
public void Should_return_all_languages() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new LanguageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var list = repository.GetAll(_siteId); Assert.AreEqual(2, list.Count); } }
public void Should_return_language_by_id() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new LanguageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var language = repository.GetById(_siteId, _languageId1); Assert.NotNull(language); } }
public async Task Should_return_all_models_for_admin() { using (var context = new MSSQLDbContext(_contextOptions)) { var facade = new LanguageFacade(DbContextShared.CreateNewContextFactory(context), new Mock <ICacheManager>().Object, Shared.CreateNewMapper()); var models = await facade.GetAllForAdminAsync(_siteId); Assert.IsNotEmpty(models); } }
public void Should_return_languages_id_list() { using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new LanguageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var list = repository.GetLanguagesIdList(_siteId); Assert.AreEqual(new List <Guid> { _languageId1, _languageId2 }, list); } }
public void Should_save_new_site() { var newSite = SiteFactory.CreateNew(Guid.NewGuid(), "Name 3"); using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Create(newSite); } using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var language = repository.GetById(newSite.Id); Assert.NotNull(language); } }
public void Should_save_new_page() { var newPage = PageFactory.Page(_siteId, Guid.NewGuid(), "Name 3"); using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new PageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Create(newPage); } using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new PageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var page = repository.GetById(_siteId, newPage.Id); Assert.NotNull(page); } }
public void Should_save_new_language() { var newLanguage = LanguageFactory.Language(_siteId, Guid.NewGuid(), "Name", "CultureName", "Url"); using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new LanguageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Create(newLanguage); } using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new LanguageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var language = repository.GetById(_siteId, newLanguage.Id); Assert.NotNull(language); } }
public void Should_save_new_menu() { var newMenu = MenuFactory.Menu(_siteId, Guid.NewGuid(), "Menu 3", "Item", ""); using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new MenuRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Create(newMenu); } using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new MenuRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var menu = repository.GetById(_siteId, newMenu.Id); Assert.NotNull(menu); } }
public void Should_save_new_theme() { var newTheme = ThemeFactory.Theme(Guid.NewGuid(), "Name 3", "Description 3", "Folder 3"); using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new ThemeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Create(newTheme); } using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new ThemeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var theme = repository.GetById(newTheme.Id); Assert.NotNull(theme); } }
public void Should_save_new_moduleType() { var newModuleType = ModuleTypeFactory.ModuleType(Guid.NewGuid(), "Name 3", "Title 3", "Description 3"); using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new ModuleTypeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Create(newModuleType); } using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new ModuleTypeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var moduleType = repository.GetById(newModuleType.Id); Assert.NotNull(moduleType); } }
public void Should_update_site() { const string newSiteName = "New Title 1"; var siteToUpdate = SiteFactory.CreateNew(_siteId1, newSiteName); using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Update(siteToUpdate); } using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var updatedSite = repository.GetById(_siteId1); Assert.AreEqual(newSiteName, updatedSite.Name); } }