Example #1
0
        /// <summary>
        /// Configures the specified property info.
        /// </summary>
        /// <param name="propertyInfo">The property info.</param>
        /// <returns>AbstractPropertyConfiguration.</returns>
        public override Mapper.Configuration.AbstractPropertyConfiguration Configure(System.Reflection.PropertyInfo propertyInfo)
        {
            var config = new SitecoreIdConfiguration();

            base.Configure(propertyInfo, config);
            return(config);
        }
Example #2
0
        public void MapToProperty_ItemIdAsID_ReturnsIdAsID()
        {
            //Assign
            string targetPath = "/sitecore/content/target";

            using (Db database = new Db
            {
                new Sitecore.FakeDb.DbItem("Target")
            })
            {
                var mapper   = new SitecoreIdMapper();
                var config   = new SitecoreIdConfiguration();
                var property = typeof(Stub).GetProperty("IDId");

                config.PropertyInfo = property;

                mapper.Setup(new DataMapperResolverArgs(null, config));

                var item = database.GetItem("/sitecore/content/Target");

                Assert.IsNotNull(item, "Item is null, check in Sitecore that item exists");
                var dataContext = new SitecoreDataMappingContext(null, item, null);
                var expected    = item.ID;

                //Act
                var value = mapper.MapToProperty(dataContext);

                //Assert
                Assert.AreEqual(expected, value);
            }
        }
Example #3
0
        // [ExpectedException(typeof(NotSupportedException))]
        public void MapToProperty_ItemIdAsString_ThrowsException()
        {
            //Assign
            string targetPath = "/sitecore/content/target";

            using (Db database = new Db
            {
                new Sitecore.FakeDb.DbItem("Target")
            })
            {
                var mapper   = new SitecoreIdMapper();
                var config   = new SitecoreIdConfiguration();
                var property = typeof(Stub).GetProperty("StringId");

                config.PropertyInfo = property;


                var item = database.GetItem("/sitecore/content/target");

                Assert.IsNotNull(item, "Item is null, check in Sitecore that item exists");

                //Act
                Assert.Throws <NotSupportedException>(() =>
                {
                    mapper.Setup(new DataMapperResolverArgs(null, config));
                });

                //Assert
                //Exception, not asserts
            }
        }
Example #4
0
        public void CanHandle_IncorrectPropertType_ReturnsFalse()
        {
            //Assign
            var config = new SitecoreIdConfiguration();
            var type1  = typeof(int);
            var mapper = new StubMapper(type1);

            config.PropertyInfo = typeof(Stub).GetProperty("Property");

            //Act
            var result = mapper.CanHandle(config, null);

            //Assert
            Assert.IsFalse(result);
        }
        public void MapToProperty_ItemIdAsID_ReturnsIdAsID()
        {
            //Assign
            var mapper   = new SitecoreIdMapper();
            var config   = new SitecoreIdConfiguration();
            var property = typeof(Stub).GetProperty("IDId");

            config.PropertyInfo = property;

            mapper.Setup(new DataMapperResolverArgs(null, config));

            var item = _db.GetItem("/sitecore/content/Tests/DataMappers/SitecoreIdMapper/EmptyItem");

            Assert.IsNotNull(item, "Item is null, check in Sitecore that item exists");
            var dataContext = new SitecoreDataMappingContext(null, item, null);
            var expected    = item.ID;

            //Act
            var value = mapper.MapToProperty(dataContext);

            //Assert
            Assert.AreEqual(expected, value);
        }
Example #6
0
 /// <summary>
 /// Configures the specified property info.
 /// </summary>
 /// <param name="propertyInfo">The property info.</param>
 /// <param name="config">The config.</param>
 public void Configure(PropertyInfo propertyInfo, SitecoreIdConfiguration config)
 {
     base.Configure(propertyInfo, config);
 }
 /// <summary>
 /// Configures the specified property info.
 /// </summary>
 /// <param name="propertyInfo">The property info.</param>
 /// <param name="config">The config.</param>
 public void Configure(PropertyInfo propertyInfo, SitecoreIdConfiguration config)
 {
     base.Configure(propertyInfo, config);
 }
 /// <summary>
 /// Configures the specified property info.
 /// </summary>
 /// <param name="propertyInfo">The property info.</param>
 /// <returns>AbstractPropertyConfiguration.</returns>
 public override Mapper.Configuration.AbstractPropertyConfiguration Configure(System.Reflection.PropertyInfo propertyInfo)
 {
     var config = new SitecoreIdConfiguration();
     base.Configure(propertyInfo, config);
     return config;
 }