public void Process_SiteSettingIsNotSet_SourcesAndTemplateAreNotSet([Frozen] DatasourceProviderFactory factory, GetDatasourceLocationAndTemplateFromSite processor, Item renderingItem)
        {
            var args = new GetRenderingDatasourceArgs(renderingItem);

            processor.Process(args);
            args.DatasourceRoots.Count.Should().Be(0);
            args.Prototype.Should().BeNull();
        }
        public void Process_DatasourceProvidersAreNull_SourcesAndTemplateAreNotSet([Frozen] DatasourceProviderFactory factory, GetDatasourceLocationAndTemplateFromSite processor, DbItem renderingItem, Db db, string settingName)
        {
            var setting = settingName.Replace("-", string.Empty);

            renderingItem.Add(new DbField("Datasource Location")
            {
                { "en", $"site:{setting}" }
            });
            db.Add(renderingItem);
            var rendering = db.GetItem(renderingItem.ID);
            var args      = new GetRenderingDatasourceArgs(rendering);

            processor.Process(args);
            args.DatasourceRoots.Count.Should().Be(0);
            args.Prototype.Should().BeNull();
        }
 public GetDatasourceLocationAndTemplateFromSite(DatasourceProviderFactory factory)
 {
   providerFactory = factory;
 }
        public void Process_FallbackDatasourceProviderIsNotNull_SourcesAndTemplateAreSet(IDatasourceProvider sourceProvider, [Substitute] DatasourceProviderFactory factory, DbItem renderingItem, Db db, string settingName, Item[] sources, Item sourceTemplate)
        {
            var processor = new GetDatasourceLocationAndTemplateFromSite(factory);

            sourceProvider.GetDatasources(Arg.Any <string>(), Arg.Any <Item>()).Returns(sources);
            sourceProvider.GetDatasourceTemplate(Arg.Any <string>(), Arg.Any <Item>()).Returns(sourceTemplate);
            factory.GetProvider(Arg.Any <Database>()).Returns((IDatasourceProvider)null);
            factory.GetFallbackProvider(Arg.Any <Database>()).Returns(sourceProvider);
            var setting = settingName.Replace("-", string.Empty);

            renderingItem.Add(new DbField("Datasource Location")
            {
                { "en", $"site:{setting}" }
            });
            db.Add(renderingItem);
            var rendering = db.GetItem(renderingItem.ID);
            var args      = new GetRenderingDatasourceArgs(rendering);

            processor.Process(args);
            args.DatasourceRoots.Should().Contain(sources);
            args.Prototype.Should().Be(sourceTemplate);
        }
示例#5
0
 public GetDatasourceLocationAndTemplateFromSite(DatasourceProviderFactory factory)
 {
     providerFactory = factory;
 }
        public void GetFallbackProvider_ConfigurationIsNotDefined_ShouldReturnNull(DatasourceProviderFactory factory, Database db)
        {
            var provider = factory.GetFallbackProvider(db);

            provider.Should().BeNull();
        }
 public void GetFallbackProvider_ConfigurationIsNotDefined_ShouldReturnNull(DatasourceProviderFactory factory, Database db)
 {
   var provider = factory.GetFallbackProvider(db);
   provider.Should().BeNull();
 }