public void Setup() { var loader = new AttributeConfigurationLoader( new string[] { "Glass.Sitecore.Mapper.Tests.HtmlFixtureNS, Glass.Sitecore.Mapper.Tests" } ); _context = new Context(loader, new AbstractSitecoreDataHandler[] { }); _db = global::Sitecore.Configuration.Factory.GetDatabase("master"); _sitecore = new SitecoreService(_db); _itemId = new Guid("{5864308D-A91A-4E74-B8CA-7F27372CBB73}"); _item = _db.GetItem(new ID(_itemId)); _html = new GlassHtml(_sitecore); _sltTextOriginal = _item["SingleLineText"]; _mltTextOriginal = _item["MultiLineText"]; _intOriginal = _item["Integer"]; _numberOriginal = _item["Number"]; using (new SecurityDisabler()) { _item.Editing.BeginEdit(); _item["SingleLineText"] = _sltContent; _item["MultiLineText"] = _mltContent; _item["Integer"] = _intContent; _item["Number"] = _numberContent; _item.Editing.EndEdit(); } }
public void Setup() { AttributeConfigurationLoader loader = new AttributeConfigurationLoader( new string[] { "Glass.Sitecore.Mapper.Tests.SitecoreServiceFixtureNS, Glass.Sitecore.Mapper.Tests" } ); _context = new Context(loader, new AbstractSitecoreDataHandler[] { }); }
public void Constructor_CreateInstance_NoErrors() { //Assign AttributeConfigurationLoader loader = null; //Act loader = new AttributeConfigurationLoader(new string[] { }); //Assert Assert.IsNotNull(loader); }
public void Setup() { AttributeConfigurationLoader loader = new AttributeConfigurationLoader( new string []{"Glass.Sitecore.Mapper.Tests.SitecoreServiceFixtureNS, Glass.Sitecore.Mapper.Tests"} ); _context = new Context(loader, new AbstractSitecoreDataHandler[]{new SitecoreIdDataHandler() }); _sitecore = new SitecoreService("master"); _db = global::Sitecore.Configuration.Factory.GetDatabase("master"); }
public void GetContext_ReturnsContextWithLoadedClass() { //Act AttributeConfigurationLoader loader = new AttributeConfigurationLoader( new string[] { "Glass.Sitecore.Mapper.Tests.ContextFixtureNS, Glass.Sitecore.Mapper.Tests" } ); _context = new Context(loader, new AbstractSitecoreDataHandler[] { }); InstanceContext instance = Context.GetContext(); //Assert Assert.AreEqual(2, instance.Classes.Count()); }
public void Load_TwoClassesInNamespace_OnlyOneShouldLoad() { //Assign Type testType = typeof(AttributeConfigurationLoaderFixtureNS.TestSet2.TestSet2); var namespaces = new string[] { string.Format("{0},{1}", testType.Namespace, testType.Assembly) }; AttributeConfigurationLoader loader = new AttributeConfigurationLoader(namespaces); //Act var result = loader.Load(); //Assert Assert.AreEqual(1, result.Count()); Assert.AreEqual(testType, result.First().Type); }
public void Load_SingleClass_LoadsClassNoMembers() { //Assign Type testType = typeof(AttributeConfigurationLoaderFixtureNS.TestSet1.TestSet1); var namespaces = new string []{string.Format("{0},{1}", testType.Namespace,testType.Assembly)}; AttributeConfigurationLoader loader = new AttributeConfigurationLoader(namespaces); //Act var result = loader.Load(); //Assert Assert.AreEqual(1, result.Count()); Assert.AreEqual(testType, result.First().Type); }
public void GetContext_MutlipleConfigLoadersDifferentNamespace_ReturnsContextWithLoadedClasses() { //Act AttributeConfigurationLoader loader1 = new AttributeConfigurationLoader( new string[] { "Glass.Sitecore.Mapper.Tests.ContextFixtureNS, Glass.Sitecore.Mapper.Tests" } ); AttributeConfigurationLoader loader2 = new AttributeConfigurationLoader( new string[] { "Glass.Sitecore.Mapper.Tests.ContextFixtureNS2, Glass.Sitecore.Mapper.Tests" } ); _context = new Context(loader1, loader2); InstanceContext instance = Context.GetContext(); //Assert Assert.AreEqual(4, instance.Classes.Count()); }
public void GetContext_MutlipleConfigLoadersSameNamespace_ThrowsException() { //Act AttributeConfigurationLoader loader1 = new AttributeConfigurationLoader( new string[] { "Glass.Sitecore.Mapper.Tests.ContextFixtureNS, Glass.Sitecore.Mapper.Tests" } ); AttributeConfigurationLoader loader2 = new AttributeConfigurationLoader( new string[] { "Glass.Sitecore.Mapper.Tests.ContextFixtureNS, Glass.Sitecore.Mapper.Tests" } ); _context = new Context(loader1, loader2); InstanceContext instance = Context.GetContext(); //Assert Assert.AreEqual(2, instance.Classes.Count()); }
public void Setup() { AttributeConfigurationLoader loader = new AttributeConfigurationLoader( new string[] { "Glass.Sitecore.Mapper.Tests.MiscFixtureNS, Glass.Sitecore.Mapper.Tests" } ); _context = new Context(loader, new AbstractSitecoreDataHandler[] {}); global::Sitecore.Context.Site = global::Sitecore.Configuration.Factory.GetSite("website"); _sitecore = new SitecoreService("master"); _db = global::Sitecore.Configuration.Factory.GetDatabase("master"); _test1 = _db.GetItem("/sitecore/content/Glass/Test1"); _test2 = _db.GetItem("/sitecore/content/Glass/Test2"); _test3 = _db.GetItem("/sitecore/content/Glass/Test1/Test3"); _demo = _db.GetItem("/sitecore/content/Glass/Demo"); }
public void Load_LoadsInheritedFromClass() { //Assign Type testType = typeof(AttributeConfigurationLoaderFixtureNS.TestSet6.TestSet6); var namespaces = new string[] { string.Format("{0},{1}", testType.Namespace, testType.Assembly) }; AttributeConfigurationLoader loader = new AttributeConfigurationLoader(namespaces); //Act var result = loader.Load(); //Assert Assert.AreEqual(2, result.Count()); Assert.IsTrue(result.Any(x => x.Type == testType)); Assert.AreEqual(2, result.First(x => x.Type == testType).Properties.Count()); }
public void Constructor_NoParameters() { //Assign AttributeConfigurationLoader loader = new AttributeConfigurationLoader(); //Act var result = loader.Load(); //Result Assert.IsTrue(result.Count() > 0); Console.WriteLine("Classes loaded by assembly: " + result.Count()); }
public void Constructor_LoadClassesByAssembly() { //Assign AttributeConfigurationLoader loader = new AttributeConfigurationLoader("Glass.Sitecore.Mapper.Tests"); //Act var result = loader.Load(); //Result Assert.IsTrue(result.Count() > 0); Console.WriteLine("Classes loaded by assembly: " + result.Count()); }
private static void CreateContext(AttributeConfigurationLoader loader) { Assert.ArgumentNotNull(loader, "loader"); var context = new Glass.Sitecore.Mapper.Context(loader, new GlassModuleLoader()); }