public void ConfigMapProperties_ImportMap_CanOverrideExistingPropertyConfig() { //Assign FinalStubMap finalStubMap = new FinalStubMap(); FinalStubSubClassMap finalStubSubClassMap = new FinalStubSubClassMap(); PartialStub1Map partialStub1Map = new PartialStub1Map(); PartialStub2Map partialStub2Map = new PartialStub2Map(); StubBaseMap stubBaseMap = new StubBaseMap(); SitecoreFluentConfigurationLoader loader = new SitecoreFluentConfigurationLoader(); ConfigurationMap configMap = new ConfigurationMap(new IGlassMap[] { partialStub1Map, stubBaseMap, partialStub2Map, finalStubMap, finalStubSubClassMap }); configMap.Load(loader); //Act finalStubMap.PerformMap(loader); finalStubSubClassMap.PerformMap(loader); //Assert Assert.AreEqual(5, finalStubSubClassMap.GlassType.Config.Properties.Count()); SitecoreFieldConfiguration fieldNameProperty = finalStubSubClassMap.GlassType.Config.Properties.FirstOrDefault(x => x.PropertyInfo.Name == "FieldName") as SitecoreFieldConfiguration; Assert.AreEqual("Field Other Name", fieldNameProperty.FieldName); SitecoreInfoConfiguration qwertyProperty = finalStubSubClassMap.GlassType.Config.Properties.FirstOrDefault(x => x.PropertyInfo.Name == "Qwerty") as SitecoreInfoConfiguration; Assert.AreEqual(SitecoreInfoType.Name, qwertyProperty.Type); Assert.IsNotNull(finalStubSubClassMap.GlassType.Config.IdConfig); }
public void ConfigMapProperties_MapsAllPropertiesToConfiguration() { //Assign FinalStubMap finalStubMap = new FinalStubMap(); PartialStub1Map partialStub1Map = new PartialStub1Map(); StubBaseMap stubBaseMap = new StubBaseMap(); PartialStub2Map partialStub2Map = new PartialStub2Map(); UmbracoFluentConfigurationLoader loader = new UmbracoFluentConfigurationLoader(); ConfigurationMap configMap = new ConfigurationMap(new IGlassMap[] { partialStub1Map, stubBaseMap, partialStub2Map, finalStubMap }); configMap.Load(loader); //Act finalStubMap.PerformMap(loader); partialStub1Map.PerformMap(loader); stubBaseMap.PerformMap(loader); partialStub2Map.PerformMap(loader); //Assert Assert.AreEqual(5, finalStubMap.GlassType.Config.Properties.Count()); UmbracoPropertyConfiguration fieldNameProperty = finalStubMap.GlassType.Config.Properties.FirstOrDefault(x => x.PropertyInfo.Name == "FieldName") as UmbracoPropertyConfiguration; Assert.AreEqual("Field Name", fieldNameProperty.PropertyName); UmbracoInfoConfiguration qwertyProperty = finalStubMap.GlassType.Config.Properties.FirstOrDefault(x => x.PropertyInfo.Name == "Qwerty") as UmbracoInfoConfiguration; Assert.AreEqual(UmbracoInfoType.Name, qwertyProperty.Type); Assert.IsNotNull(finalStubMap.GlassType.Config.IdConfig); }
public void General_RetrieveItemAndFieldsFromSitecore_ReturnPopulatedDerivedClass() { //Assign string fieldValue = "test field value"; Guid id = new Guid("{A544AE18-BC21-457D-8852-438F53AAE7E1}"); string name = "Target"; var db = Sitecore.Configuration.Factory.GetDatabase("master"); DependencyResolver resolver = Utilities.CreateStandardResolver() as DependencyResolver; resolver.Container.Register(Component.For <IDependencyResolver>().Instance(resolver)); resolver.Container.Register( Component.For <IGlassMap, SitecoreGlassMap <SuperStub> >() .ImplementedBy <SuperStubMap>() .LifestyleCustom <NoTrackLifestyleManager>()); resolver.Container.Register( Component.For <IGlassMap, SitecoreGlassMap <IStub> >() .ImplementedBy <StubInterfaceMap>() .LifestyleCustom <NoTrackLifestyleManager>()); resolver.Container.Register( Component.For <IGlassMap, SitecoreGlassMap <Stub> >() .ImplementedBy <StubMap>() .LifestyleCustom <NoTrackLifestyleManager>()); var context = Context.Create(resolver); var loader = new SitecoreFluentConfigurationLoader(); ConfigurationMap map = new ConfigurationMap(resolver); map.Load(loader); context.Load(loader); var item = db.GetItem(new ID(id)); using (new ItemEditing(item, true)) { item["Field"] = fieldValue; } var service = new SitecoreService(db, context); //Act var result = service.GetItem <SuperStub>(id); //Assert Assert.AreEqual(fieldValue, result.Field); Assert.AreEqual(id, result.Id); Assert.AreEqual(name, result.Name); Assert.AreEqual("/en/sitecore/content/Tests/Configuration/Fluent/Target.aspx", result.Url); Assert.AreEqual("Random String", result.DelegatedField); }
public void ConfigMapProperties_MapsSinglePropertyToConfiguration() { //Assign StubBaseMap stubMap = new StubBaseMap(); SitecoreFluentConfigurationLoader loader = new SitecoreFluentConfigurationLoader(); ConfigurationMap configMap = new ConfigurationMap(new IGlassMap[] { stubMap }); configMap.Load(loader); //Act stubMap.PerformMap(loader); //Assert Assert.AreEqual(1, stubMap.GlassType.Config.Properties.Count()); Assert.IsNull(stubMap.GlassType.Config.ItemConfig); }
public void Issue254_Test() { MapStubWithChildren mapStubWithChildren = new MapStubWithChildren(); MapStubInherit1 mapStubInherit1 = new MapStubInherit1(); MapStubInherit2 mapStubInherit2 = new MapStubInherit2(); SitecoreFluentConfigurationLoader loader = new SitecoreFluentConfigurationLoader(); ConfigurationMap configMap = new ConfigurationMap(new IGlassMap[] { mapStubWithChildren, mapStubInherit1, mapStubInherit2 }); configMap.Load(loader); //Assert //Assert Assert.IsTrue(mapStubWithChildren.GlassType.Config.Properties.Any(x => x is SitecoreChildrenConfiguration)); Assert.IsTrue(mapStubInherit1.GlassType.Config.Properties.Any(x => x is SitecoreChildrenConfiguration)); Assert.IsTrue(mapStubInherit2.GlassType.Config.Properties.Any(x => x is SitecoreChildrenConfiguration)); }