コード例 #1
0
        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);
            }
        }
コード例 #2
0
        public static IDbContextFactory CreateNewContextFactory(MSSQLDbContext context)
        {
            var dbContextFactoryMock = new Mock <IDbContextFactory>();

            dbContextFactoryMock.Setup(x => x.Create()).Returns(context);
            return(dbContextFactoryMock.Object);
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        public static void Main(string[] args)
        {
            MSSQLDbContext db = new MSSQLDbContext();

            db.Database.EnsureCreated();
            CreateHostBuilder(args).Build().Run();
        }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        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);
            }
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
        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());
            }
        }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
        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);
            }
        }
コード例 #16
0
        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);
            }
        }
コード例 #17
0
        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);
            }
        }
コード例 #18
0
        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);
            }
        }
コード例 #19
0
        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));
            }
        }
コード例 #20
0
        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);
            }
        }
コード例 #21
0
        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);
            }
        }
コード例 #22
0
        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);
            }
        }
コード例 #23
0
        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);
            }
        }
コード例 #24
0
        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);
            }
        }
コード例 #25
0
        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);
            }
        }
コード例 #26
0
        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);
            }
        }
コード例 #27
0
        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);
            }
        }
コード例 #28
0
        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);
            }
        }
コード例 #29
0
        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);
            }
        }
コード例 #30
0
        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);
            }
        }