CanHandle() 공개 메소드

Indicates that the data mapper will mapper to and from the property
public CanHandle ( AbstractPropertyConfiguration configuration, Context context ) : bool
configuration Glass.Mapper.Configuration.AbstractPropertyConfiguration The configuration.
context Context The context.
리턴 bool
        public void CanHandle_CorrectConfigIEnumerableNotMappedClass_ReturnsTrueOnDemand()
        {
            //Assign
            var mapper = new SitecoreQueryMapper(null);
            var config = new SitecoreQueryConfiguration();
            config.PropertyInfo = new FakePropertyInfo(typeof(IEnumerable<StubNotMapped>));
            var context = Context.Create(Utilities.CreateStandardResolver());
            context.Load(new SitecoreAttributeConfigurationLoader("Glass.Mapper.Sc.Integration"));


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

            //Assert
            Assert.IsTrue(result);
        }
        public void CanHandle_CorrectConfigIEnumerableMappedClass_ReturnsTrue()
        {
            //Assign
            var mapper = new SitecoreQueryMapper(null);
            var config = new SitecoreQueryConfiguration();
            config.PropertyInfo = typeof(StubClass).GetProperty("StubMappeds");


            var context = Context.Create(Utilities.CreateStandardResolver());
            context.Load(new OnDemandLoader<SitecoreTypeConfiguration>(typeof(StubClass)));



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

            //Assert
            Assert.IsTrue(result);
        }
        public void CanHandle_IncorrectConfigMappedClass_ReturnsFalse()
        {
            //Assign
            var mapper = new SitecoreQueryMapper(null);
            var config = new SitecoreFieldConfiguration();
            config.PropertyInfo = typeof (StubClass).GetProperty("StubMapped");

            var context = Context.Create(Utilities.CreateStandardResolver());
            context.Load(new SitecoreAttributeConfigurationLoader("Glass.Mapper.Sc.Integration"));


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

            //Assert
            Assert.IsFalse(result);
        }