Example #1
0
        public void ConfigMapProperties_MapsAllPropertiesToConfiguration()
        {
            //Assign
            FinalStubMap    finalStubMap    = new FinalStubMap();
            PartialStub1Map partialStub1Map = new PartialStub1Map();
            StubBaseMap     stubBaseMap     = new StubBaseMap();
            PartialStub2Map partialStub2Map = new PartialStub2Map();

            SitecoreFluentConfigurationLoader loader = new SitecoreFluentConfigurationLoader();
            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());
            SitecoreFieldConfiguration fieldNameProperty = finalStubMap.GlassType.Config.Properties.FirstOrDefault(x => x.PropertyInfo.Name == "FieldName") as SitecoreFieldConfiguration;

            Assert.AreEqual("Field Name", fieldNameProperty.FieldName);

            SitecoreInfoConfiguration qwertyProperty = finalStubMap.GlassType.Config.Properties.FirstOrDefault(x => x.PropertyInfo.Name == "Qwerty") as SitecoreInfoConfiguration;

            Assert.AreEqual(SitecoreInfoType.Name, qwertyProperty.Type);

            Assert.IsNotNull(finalStubMap.GlassType.Config.IdConfig);
        }
        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);            
        }