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);
            }
        }
Example #2
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 WeapsyDbContext(_contextOptions))
            {
                var repository = new MenuRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                repository.Update(menuToUpdate);
            }

            using (var context = new WeapsyDbContext(_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 void Should_return_all_models()
 {
     using (var context = new MSSQLDbContext(_contextOptions))
     {
         var facade = new EmailAccountFacade(DbContextShared.CreateNewContextFactory(context), new Mock <ICacheManager>().Object, Shared.CreateNewMapper());
         var models = facade.GetAll(_siteId);
         Assert.IsNotEmpty(models);
     }
 }
Example #4
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);
     }
 }
 public void Should_return_model()
 {
     using (var context = new WeapsyDbContext(_contextOptions))
     {
         var facade = new EmailAccountFacade(DbContextShared.CreateNewContextFactory(context), new Mock <ICacheManager>().Object, Shared.CreateNewMapper());
         var model  = facade.Get(_siteId, _emailAccountId);
         Assert.NotNull(model);
     }
 }
Example #6
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);
            }
        }
        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_culture_name()
        {
            using (var context = new MSSQLDbContext(_contextOptions))
            {
                var repository = new LanguageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var language   = repository.GetByCultureName(_siteId, "ab1");

                Assert.NotNull(language);
            }
        }
        public async Task Should_return_model_for_admin()
        {
            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var handler = new GetForAdminHandler(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var model   = await handler.RetrieveAsync(new GetForAdmin { SiteId = _siteId, Id = _languageId });

                Assert.NotNull(model);
            }
        }
Example #10
0
        public void Should_return_menu_by_name_with_no_deleted_menu_items()
        {
            using (var context = new WeapsyDbContext(_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());
            }
        }
Example #11
0
        public void Should_return_menu_by_name()
        {
            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new MenuRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var menu       = repository.GetByName(_siteId, "Menu 1");

                Assert.NotNull(menu);
            }
        }
Example #12
0
        public void Should_return_null_if_menu_is_deleted()
        {
            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new MenuRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var menu       = repository.GetById(_deletedMenuId);

                Assert.Null(menu);
            }
        }
Example #13
0
        public void Should_return_count_by_module_type_id()
        {
            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new ModuleRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var count      = repository.GetCountByModuleTypeId(_moduleTypeId1);

                Assert.AreEqual(1, count);
            }
        }
Example #14
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);
            }
        }
        public void Should_return_language_by_id_only()
        {
            using (var context = new MSSQLDbContext(_contextOptions))
            {
                var repository = new LanguageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var language   = repository.GetById(_languageId1);

                Assert.NotNull(language);
            }
        }
Example #16
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);
            }
        }
Example #17
0
        public void Should_return_languages_count()
        {
            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new LanguageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var count      = repository.GetLanguagesCount(_siteId);

                Assert.AreEqual(2, count);
            }
        }
Example #18
0
        public void Should_return_module_type_by_id()
        {
            using (var context = new MSSQLDbContext(_contextOptions))
            {
                var repository = new ModuleTypeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var moduleType = repository.GetById(_moduleTypeId1);

                Assert.NotNull(moduleType);
            }
        }
Example #19
0
        public async Task Should_return_all_models()
        {
            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var handler = new GetAllEmailAccountsHandler(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var models  = await handler.RetrieveAsync(new GetAllEmailAccounts { SiteId = _siteId });

                Assert.IsNotEmpty(models);
            }
        }
Example #20
0
        public void Should_return_page_id_by_localised_slug()
        {
            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new PageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var pageId     = repository.GetPageIdByLocalisedSlug(_siteId, "localised-url-1");

                Assert.AreNotEqual(Guid.Empty, pageId);
            }
        }
Example #21
0
        public void Should_return_menu_by_id()
        {
            using (var context = new MSSQLDbContext(_contextOptions))
            {
                var repository = new MenuRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var menu       = repository.GetById(_siteId, _menuId1);

                Assert.NotNull(menu);
            }
        }
Example #22
0
        public void Should_return_page_by_id_with_no_deleted_page_modules()
        {
            using (var context = new WeapsyDbContext(_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));
            }
        }
Example #23
0
        public void Should_return_page_id_by_name()
        {
            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new PageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var pageId     = repository.GetPageIdByName(_siteId, "Name 2");

                Assert.AreEqual(_pageId2, pageId);
            }
        }
Example #24
0
        public void Should_return_null_if_page_is_deleted()
        {
            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new PageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var page       = repository.GetById(_deletedPageId);

                Assert.Null(page);
            }
        }
Example #25
0
        public void Should_return_page_by_id()
        {
            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new PageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var page       = repository.GetById(_siteId, _pageId1);

                Assert.NotNull(page);
            }
        }
        public void Should_return_module_type_by_name()
        {
            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new ModuleTypeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var moduleType = repository.GetByName("Name 1");

                Assert.NotNull(moduleType);
            }
        }
        public void Should_return_null_if_module_type_is_deleted()
        {
            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new ModuleTypeRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var moduleType = repository.GetById(_deletedModuleTypeId);

                Assert.Null(moduleType);
            }
        }
Example #28
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);
            }
        }
Example #29
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);
            }
        }
Example #30
0
 public void Should_return_model()
 {
     using (var context = new WeapsyDbContext(_contextOptions))
     {
         var handler = new GetEmailAccountHandler(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
         var model   = handler.RetrieveAsync(new GetEmailAccount {
             SiteId = _siteId, Id = _emailAccountId
         });
         Assert.NotNull(model);
     }
 }