コード例 #1
0
        public void GlassValueProviderProcessor_Stops_If_RequestedType_Is_Not_In_TypeConfigurations()
        {
            //Arrange
            var depenencyResolver = new Mock <IDependencyResolver>();
            var glassContext      = Context.Create(depenencyResolver.Object);
            var sitecoreContext   = new Mock <ISitecoreContext>();

            sitecoreContext.Setup(ctx => ctx.GlassContext).Returns(glassContext);

            var processor = new MockGlassValueProviderProcessor(sitecoreContext.Object, "something not null");
            var args      = new ValueProviderArgs(typeof(MockGlassValueProviderProcessor));

            //Act
            processor.Process(args);

            //Assert
            Assert.IsNull(args.Result);
        }
コード例 #2
0
        public void GlassValueProviderProcessor_Skips_TypeConfiguration_Check_If_Disabled()
        {
            //Arrange
            var depenencyResolver = new Mock <IDependencyResolver>();
            var glassContext      = Context.Create(depenencyResolver.Object);
            var sitecoreContext   = new Mock <ISitecoreContext>();

            sitecoreContext.Setup(ctx => ctx.GlassContext).Returns(glassContext);

            var processor = new MockGlassValueProviderProcessor(sitecoreContext.Object, "something not null")
            {
                DisableTypeConfigurationCheck = true
            };
            var args = new ValueProviderArgs(typeof(MockGlassValueProviderProcessor));

            //Act
            processor.Process(args);

            //Assert
            Assert.AreEqual(args.Result, "something not null");
        }
コード例 #3
0
        public void GlassValueProviderProcessor_Gets_Results_If_RequestedType_Is_In_TypeConfigurations()
        {
            //Arrange
            var depenencyResolver = new Mock <IDependencyResolver>();
            var glassContext      = Context.Create(depenencyResolver.Object);

            glassContext.TypeConfigurations.AddOrUpdate(typeof(string), type => new SitecoreTypeConfiguration(), (type, configuration) => configuration);

            var sitecoreContext = new Mock <ISitecoreContext>();

            sitecoreContext.Setup(ctx => ctx.GlassContext).Returns(glassContext);

            var processor = new MockGlassValueProviderProcessor(sitecoreContext.Object, "something not null");
            var args      = new ValueProviderArgs(typeof(string));

            //Act
            processor.Process(args);

            //Assert
            Assert.AreEqual(args.Result, "something not null");
        }