private void ResolveDatasource(GetRenderingDatasourceArgs args) { var contextItem = args.ContentDatabase.GetItem(args.ContextItemPath); var source = args.RenderingItem[Templates.RenderingOptions.Fields.DatasourceLocation]; var name = DatasourceConfigurationService.GetSiteDatasourceConfigurationName(source); if (string.IsNullOrEmpty(name)) { return; } var datasourceLocations = _provider.GetDatasourceLocations(contextItem, name); args.DatasourceRoots.AddRange(datasourceLocations); }
public void Process_DatasourceProviderIsNotNull_SourcesAndTemplateAreSet(IDatasourceProvider provider, DbItem renderingItem, Db db, string settingName, Item[] sources, Item sourceTemplate) { provider.GetDatasourceLocations(Arg.Any<Item>(), Arg.Any<string>()).Returns(sources); provider.GetDatasourceTemplate(Arg.Any<Item>(), Arg.Any<string>()).Returns(sourceTemplate); var setting = settingName.Replace("-", string.Empty); renderingItem.Add(new DbField(Templates.RenderingOptions.Fields.DatasourceLocation) { { "en", $"site:{setting}" } }); db.Add(renderingItem); var rendering = db.GetItem(renderingItem.ID); var processor = new GetDatasourceLocationAndTemplateFromSite(provider); var args = new GetRenderingDatasourceArgs(rendering); processor.Process(args); args.DatasourceRoots.Should().Contain(sources); args.Prototype.Should().Be(sourceTemplate); }
public void Process_DatasourceProviderIsNotNull_SourcesAndTemplateAreSet(IDatasourceProvider provider, DbItem renderingItem, Db db, string settingName, Item[] sources, Item sourceTemplate) { provider.GetDatasourceLocations(Arg.Any <Item>(), Arg.Any <string>()).Returns(sources); provider.GetDatasourceTemplate(Arg.Any <Item>(), Arg.Any <string>()).Returns(sourceTemplate); var setting = settingName.Replace("-", string.Empty); renderingItem.Add(new DbField(Templates.RenderingOptions.Fields.DatasourceLocation) { { "en", $"site:{setting}" } }); db.Add(renderingItem); var rendering = db.GetItem(renderingItem.ID); var processor = new GetDatasourceLocationAndTemplateFromSite(provider); var args = new GetRenderingDatasourceArgs(rendering); processor.Process(args); args.DatasourceRoots.Should().Contain(sources); args.Prototype.Should().Be(sourceTemplate); }