Esempio n. 1
0
        public void GetSettingsItem_ShouldReturnSettingItem(string settingName, [Frozen] Item contextItem, [Substitute] SiteContext context, Db db, string definitionItemName)
        {
            var provider      = new SiteSettingsProvider(context);
            var settingItemId = ID.NewID;
            var definitionId  = ID.NewID;

            db.Add(new DbItem(definitionItemName, definitionId)
            {
                new DbItem(SiteSettingsProvider.SettingsRootName)
                {
                    new DbItem(DatasourceProvider.DatasourceSettingsName, ID.NewID, Templates.SiteSettings.ID)
                    {
                        new DbItem(settingName, settingItemId)
                    }
                }
            });
            var definitionItem = db.GetItem(definitionId);
            var setting        = db.GetItem(settingItemId);

            context.GetSiteDefinition(Arg.Any <Item>()).Returns(new SiteDefinition {
                Item = definitionItem
            });
            var settingItem = provider.GetSetting(contextItem, DatasourceProvider.DatasourceSettingsName, settingName);

            settingItem.ID.ShouldBeEquivalentTo(setting.ID);
        }
Esempio n. 2
0
        public void GetSettingsItem_SiteDefinitionDoesNotExists_ShouldReturnNull(string settingName, [Frozen] Item contextItem, [Substitute] SiteContext context, Db db, string definitionItemName)
        {
            var provider = new SiteSettingsProvider(context);

            context.GetSiteDefinition(Arg.Any <Item>()).Returns((SiteDefinition)null);
            var settingItem = provider.GetSetting(contextItem, DatasourceProvider.DatasourceSettingsName, settingName);

            settingItem.Should().BeNull();
        }