Class SitecoreIdMapper
Наследование: AbstractDataMapper
        public void MapToProperty_ItemIdAsGuid_ReturnsIdAsGuid()
        {
            //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("GuidId");
                var item = database.GetItem("/sitecore/content/target");

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

                config.PropertyInfo = property;

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

                var dataContext = new SitecoreDataMappingContext(null, item, null);
                var expected = item.ID.Guid;

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

                //Assert
                Assert.AreEqual(expected, value);
            }
        }
        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_ItemIdAsGuid_ReturnsIdAsGuid()
        {
            //Assign
            var mapper = new SitecoreIdMapper();
            var config = new SitecoreIdConfiguration();
            var property = typeof (Stub).GetProperty("GuidId");
            var item = _db.GetItem("/sitecore/content/Tests/DataMappers/SitecoreIdMapper/EmptyItem");

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

            config.PropertyInfo = property;
            
            mapper.Setup(new DataMapperResolverArgs(null,config));

            var dataContext = new SitecoreDataMappingContext(null, item, null);
            var expected = item.ID.Guid;

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

            //Assert
            Assert.AreEqual(expected, value);
        }
       // [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 MapToProperty_ItemIdAsString_ThrowsException()
        {
            //Assign
            var mapper = new SitecoreIdMapper();
            var config = new SitecoreIdConfiguration();
            var property = typeof(Stub).GetProperty("StringId");

            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
            //Exception, not asserts
        }