public void GetSiteDefinitions_ShouldReturnSiteDefinitiosModel([Frozen] ISiteDefinitionsProvider siteDefinitionProvider, [Greedy] SiteConfigurationRepository repository, string name)
        {
            var id = ID.NewID;
            var db = new Db
            {
                new DbItem(name, id, MultiSite.Templates.SiteConfiguration.ID)
                {
                    new DbField(MultiSite.Templates.SiteConfiguration.Fields.ShowInMenu)
                    {
                        { "en", "1" }
                    }
                }
            };

            var item = db.GetItem(id);

            siteDefinitionProvider.SiteDefinitions.Returns(new List <Foundation.MultiSite.SiteDefinition> {
                new Foundation.MultiSite.SiteDefinition {
                    Item = item
                }
            });
            var definitions = repository.Get();

            definitions.Should().BeOfType <SiteConfigurations>();
            var sites = definitions.Items.ToList();

            sites.Count.Should().BeGreaterThan(0);
        }
        public void GetSiteDefinitions_ShouldReturnSiteDefinitiosModel([Frozen] ISiteDefinitionsProvider siteDefinitionProvider, [Greedy] SiteConfigurationRepository repository, string name)
        {
            var id = ID.NewID;
            var db = new Db
            {
                new DbItem(name, id, Multisite.Templates.SiteConfiguration.ID)
                {
                    new SharedDbField(Multisite.Templates.SiteConfiguration.Fields.ShowInMenu)
                    {
                        Value = "1"
                    }
                }
            };
            var item = db.GetItem(id);

            var siteSettings = new StringDictionary()
            {
                { "name", name },
            };

            siteDefinitionProvider.SiteDefinitions.Returns(new List <SiteDefinition> {
                new SiteDefinition {
                    Item = item, Site = new SiteInfo(siteSettings)
                }
            });
            var definitions = repository.Get();

            definitions.Should().BeOfType <SiteConfigurations>();
            var sites = definitions.Items.ToList();

            sites.Count.Should().BeGreaterThan(0);
        }
示例#3
0
        public SiteSettingsProviderTests()
        {
            this.siteDefinitionsProvider = Substitute.For <ISiteDefinitionsProvider>();
            this.sitecoreService         = Substitute.For <ISitecoreService>();

            this.provider = new SiteSettingsProvider(this.siteDefinitionsProvider, this.sitecoreService);
        }
 public CatalogItemResolver(ISearchManager searchManager, IPageTypeProvider pageTypeProvider, IStorefrontContext storefrontContext, ISiteDefinitionsProvider siteDefinitionsProvider, ISiteContext siteContext, IAnalyticsManager analyticsManager)
 {
     this.searchManager           = searchManager;
     this.pageTypeProvider        = pageTypeProvider;
     this.storefrontContext       = storefrontContext;
     this.siteDefinitionsProvider = siteDefinitionsProvider;
     this.siteContext             = siteContext;
 }
示例#5
0
        public SiteSettingsProvider(ISiteDefinitionsProvider siteDefinitionsProvider, ISitecoreService sitecoreService)
        {
            Assert.ArgumentNotNull(siteDefinitionsProvider, nameof(siteDefinitionsProvider));
            Assert.ArgumentNotNull(sitecoreService, nameof(sitecoreService));

            this.siteDefinitionsProvider = siteDefinitionsProvider;
            this.sitecoreService         = sitecoreService;
        }
示例#6
0
    public void GetSiteDefinition_ProviderReturnsEmpty_ShouldReturnNull(ISiteDefinitionsProvider provider, DbItem item, Db db, string siteName)
    {
      db.Add(item);
      var contextItem = db.GetItem(item.ID);

      provider.GetContextSiteDefinition(Arg.Any<Item>()).Returns((SiteDefinition)null);

      var siteContext = new SiteContext(provider);
      siteContext.GetSiteDefinition(contextItem).ShouldBeEquivalentTo(null);
    }
示例#7
0
        public void GetSiteDefinition_ProviderReturnsEmpty_ShouldReturnNull(ISiteDefinitionsProvider provider, DbItem item, Db db, string siteName)
        {
            db.Add(item);
            var contextItem = db.GetItem(item.ID);

            provider.GetContextSiteDefinition(Arg.Any <Item>()).Returns((SiteDefinition)null);

            var siteContext = new SiteContext(provider);

            siteContext.GetSiteDefinition(contextItem).Should().BeNull();
        }
 public CatalogItemResolver(
     ISearchService searchService,
     IPageTypeProvider pageTypeProvider,
     IStorefrontContext storefrontContext,
     ISiteDefinitionsProvider siteDefinitionsProvider,
     ISiteContext siteContext)
 {
     this.searchService           = searchService;
     this.pageTypeProvider        = pageTypeProvider;
     this.storefrontContext       = storefrontContext;
     this.siteDefinitionsProvider = siteDefinitionsProvider;
     this.siteContext             = siteContext;
 }
示例#9
0
    public void GetSiteDefinition_ProviderReturnsDefinition_ShouldReturnDefinition(ISiteDefinitionsProvider provider, DbItem item, Db db, string siteName)
    {
      var siteDefinitionId = ID.NewID;
      db.Add(new DbItem(siteName, siteDefinitionId, Templates.Site.ID) { item });
      var definitionItem = db.GetItem(siteDefinitionId);

      var definition = new SiteDefinition();
      definition.Item = definitionItem;
      provider.GetContextSiteDefinition(Arg.Any<Item>()).Returns(definition);

      var siteContext = new SiteContext(provider);

      var contextItem = db.GetItem(item.ID);
      var siteDefinition = siteContext.GetSiteDefinition(contextItem);

      siteDefinition.Item.ID.ShouldBeEquivalentTo(definitionItem.ID);
    }
示例#10
0
        public void GetSupportedLanguages_OneSelected_ShouldReturnSelected(Db db, [Content] DbTemplate template, DbItem item, string rootName, ISiteDefinitionsProvider siteProvider)
        {
            const string supportedLanguage = "en";
            const string url = "/lorem/";

            // Arrange
            template.BaseIDs = new[]
            {
                Templates.Site.ID, Feature.Language.Templates.LanguageSettings.ID
            };

            var languageItem = new DbItem(supportedLanguage);

            db.Add(languageItem);

            var siteRootId   = ID.NewID;
            var siteRootItem = new DbItem(rootName, siteRootId, template.ID)
            {
                new DbField(Feature.Language.Templates.LanguageSettings.Fields.SupportedLanguages)
                {
                    {
                        supportedLanguage, languageItem.ID.ToString()
                    }
                }
            };

            siteRootItem.Add(item);
            db.Add(siteRootItem);
            var contextItem = db.GetItem(item.ID);

            var linkManager = new Mock <BaseLinkManager>();

            linkManager.Setup(x => x.GetItemUrl(contextItem, It.IsAny <UrlOptions>())).Returns(url);

            var siteContext = new Mock <Foundation.Multisite.SiteContext>(siteProvider);

            siteContext.Setup(x => x.GetSiteDefinition(contextItem)).Returns(new SiteDefinition
            {
                Item = db.GetItem(siteRootId)
            });
            var repository = new LanguageRepository(siteContext.Object, linkManager.Object);

            using (new ContextItemSwitcher(contextItem))
            {
                // Act
                var supportedLanguages = repository.GetSupportedLanguages();

                // Assert
                supportedLanguages.Count().Should().BeGreaterThan(0);
                supportedLanguages.First().TwoLetterCode.Should().Be(supportedLanguage);
                supportedLanguages.First().Url.Should().Be(url);
            }
        }
示例#11
0
 public SiteContext(ISiteDefinitionsProvider siteDefinitionsProvider)
 {
     this.siteDefinitionsProvider = siteDefinitionsProvider;
 }
示例#12
0
 public SiteConfigurationRepository(ISiteDefinitionsProvider itemSiteDefinitionsProvider)
 {
     this.siteDefinitionsProvider = itemSiteDefinitionsProvider;
 }
 public SiteConfigurationRepository(ISiteDefinitionsProvider itemSiteDefinitionsProvider)
 {
   this.siteDefinitionsProvider = itemSiteDefinitionsProvider;
 }
 public void Constructor_InstanceOfISiteDefinitionInterface_InstanceShouldBeCreated(ISiteDefinitionsProvider provider, SiteDefinitionsRepository multisiteRepository)
 {
   Action action = () => new SiteDefinitionsRepository(provider);
   action.ShouldNotThrow();
 }
        public void Constructor_InstanceOfISiteDefinitionInterface_InstanceShouldBeCreated(ISiteDefinitionsProvider provider, SiteConfigurationRepository multisiteRepository)
        {
            Action action = () => new SiteConfigurationRepository(provider);

            action.Should().NotThrow();
        }
示例#16
0
 public SiteContext(ISiteDefinitionsProvider siteDefinitionsProvider)
 {
   this.siteDefinitionsProvider = siteDefinitionsProvider;
 }
示例#17
0
        public void GetSupportedLanguages_NoneSelected_ShouldReturnEmptyList(Db db, [Content] DbTemplate template, DbItem item, string rootName, ISiteDefinitionsProvider siteProvider, BaseLinkManager linkManager)
        {
            // Arrange
            template.BaseIDs = new[]
            {
                Templates.Site.ID, Feature.Language.Templates.LanguageSettings.ID
            };

            var languageItem = new DbItem("en");

            db.Add(languageItem);

            var siteRootId   = ID.NewID;
            var siteRootItem = new DbItem(rootName, siteRootId, template.ID)
            {
                new DbField(Feature.Language.Templates.LanguageSettings.Fields.SupportedLanguages)
                {
                    {
                        "en", ""
                    }
                }
            };

            siteRootItem.Add(item);
            db.Add(siteRootItem);
            var contextItem = db.GetItem(item.ID);

            var siteContext = new Mock <Foundation.Multisite.SiteContext>(siteProvider);

            siteContext.Setup(x => x.GetSiteDefinition(contextItem)).Returns(new SiteDefinition
            {
                Item = db.GetItem(siteRootId)
            });
            var repository = new LanguageRepository(siteContext.Object, linkManager);

            var fakeSite = new FakeSiteContext(new StringDictionary()
            {
                { "name", "fake" },
                { "database", "master" },
                { "rootPath", siteRootItem.FullPath },
                { "hostName", "local" }
            });

            using (new FakeSiteContextSwitcher(fakeSite))
            {
                using (new ContextItemSwitcher(contextItem))
                {
                    // Act
                    var supportedLanguages = repository.GetSupportedLanguages();

                    // Assert
                    supportedLanguages.Count().Should().Be(0);
                }
            }
        }
示例#18
0
        public void GetSiteDefinition_ProviderReturnsDefinition_ShouldReturnDefinition(ISiteDefinitionsProvider provider, DbItem item, Db db, string siteName)
        {
            var siteDefinitionId = ID.NewID;

            db.Add(new DbItem(siteName, siteDefinitionId, Templates.Site.ID)
            {
                item
            });
            var definitionItem = db.GetItem(siteDefinitionId);

            var definition = new SiteDefinition();

            definition.Item = definitionItem;
            provider.GetContextSiteDefinition(Arg.Any <Item>()).Returns(definition);

            var siteContext = new SiteContext(provider);

            var contextItem    = db.GetItem(item.ID);
            var siteDefinition = siteContext.GetSiteDefinition(contextItem);

            siteDefinition.Item.ID.Should().BeEquivalentTo(definitionItem.ID);
        }
示例#19
0
 public SiteDefinitionsRepository(ISiteDefinitionsProvider itemSiteDefinitionsProvider)
 {
   siteDefinitionsProvider = itemSiteDefinitionsProvider;
 }