Пример #1
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);
            }
        }
Пример #2
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
            }
        }
        public void ReadOnly_ReturnsTrue()
        {
            //Assign
            var  mapper   = new SitecoreIdMapper();
            bool expected = true;

            //Act
            bool value = mapper.ReadOnly;


            //Assert
            Assert.AreEqual(expected, value);
        }
        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);
        }