示例#1
0
        public void GetRenderingParameters_UsingClassNoValue_ReturnsFieldWithValue()
        {
            //Arrange
            var templateId = ID.NewID;
            var targetId   = ID.NewID;
            var fieldName  = "StringField";

            using (Db database = new Db
            {
                new DbTemplate(templateId)
                {
                    { fieldName, "" }
                },
                new Sitecore.FakeDb.DbItem("Target", targetId, templateId),
            })
            {
                var resolver = Utilities.CreateStandardResolver();

                var context = Context.Create(resolver);
                var db      = database.Database;
                var control = new StubAbstractGlassUserControl(new WebFormsContext(new SitecoreService(db, context)));

                Sitecore.Context.Database = db;
                var sublayout = new Sublayout();
                sublayout.Parameters = string.Empty;

                sublayout.Controls.Add(control);

                //Act
                var result = control.GetRenderingParameters <GlassTestRenderingParameters>();

                //Act
                Assert.AreEqual(null, result);
            }
        }
        public void GetRenderingParameters_UsingInterfaceWithValue_ReturnsFieldWithValue()
        {
            //Arrange
            var templateId = new ID("{6C815B38-4D88-4F01-916D-8D7C6548005E}");
            var targetId   = ID.NewID;
            var fieldName  = "StringField";

            using (Db database = new Db
            {
                new DbTemplate(templateId)
                {
                    { fieldName, "" }
                },
                new Sitecore.FakeDb.DbItem("Target", targetId, templateId),
            })
            {
                var control  = new StubAbstractGlassUserControl();
                var resolver = Utilities.CreateStandardResolver();
                var context  = Context.Create(resolver);
                var db       = database.Database;

                Sitecore.Context.Database = db;
                control.SitecoreContext   = new SitecoreContext(context);
                var sublayout = new Sublayout();
                sublayout.Parameters = "StringField=efefefef";

                sublayout.Controls.Add(control);

                //Act
                var result = control.GetRenderingParameters <IGlassTestRenderingParameters>();

                //Act
                Assert.AreEqual("efefefef", result.StringField);
            }
        }
        public void GetRenderingParameters_UsingInterfaceWithValue_ReturnsFieldWithValue()
        {
            //Arrange
            var control = new StubAbstractGlassUserControl();
            var resolver = Utilities.CreateStandardResolver();
            var context = Context.Create(resolver);
            var db = Sitecore.Configuration.Factory.GetDatabase("master");

            Sitecore.Context.Database = db;
            control.SitecoreContext = new SitecoreContext(context);
            var sublayout = new Sublayout();
            sublayout.Parameters = "StringField=efefefef";

            sublayout.Controls.Add(control);

            //Act
            var result = control.GetRenderingParameters<IGlassTestRenderingParameters>();

            //Act
            Assert.AreEqual("efefefef", result.StringField);
        }
示例#4
0
        public void GetRenderingParameters_UsingInterfaceNoValue_ReturnsFieldWithValue()
        {
            //Arrange
            var control  = new StubAbstractGlassUserControl();
            var resolver = Utilities.CreateStandardResolver();
            var context  = Context.Create(resolver);
            var db       = Sitecore.Configuration.Factory.GetDatabase("master");

            Sitecore.Context.Database = db;
            control.SitecoreContext   = new SitecoreContext(context);
            var sublayout = new Sublayout();

            sublayout.Parameters = string.Empty;

            sublayout.Controls.Add(control);

            //Act
            var result = control.GetRenderingParameters <IGlassTestRenderingParameters>();

            //Act
            Assert.AreEqual(null, result);
        }
        public void GetRenderingParameters_UsingInterfaceWithValue_ReturnsFieldWithValue()
        {
            //Arrange
            var templateId = new ID("{6C815B38-4D88-4F01-916D-8D7C6548005E}");
            var targetId = ID.NewID;
            var fieldName = "StringField";

            using (Db database = new Db
            {
                new DbTemplate(templateId)
                {
                    {fieldName, ""}
                },
                new Sitecore.FakeDb.DbItem("Target", targetId, templateId),

            })
            {
                var control = new StubAbstractGlassUserControl();
                var resolver = Utilities.CreateStandardResolver();
                var context = Context.Create(resolver);
                var db = database.Database;

                Sitecore.Context.Database = db;
                control.SitecoreContext = new SitecoreContext(context);
                var sublayout = new Sublayout();
                sublayout.Parameters = "StringField=efefefef";

                sublayout.Controls.Add(control);

                //Act
                var result = control.GetRenderingParameters<IGlassTestRenderingParameters>();

                //Act
                Assert.AreEqual("efefefef", result.StringField);
            }
        }
        public void GetRenderingParameters_UsingClassNoValue_ReturnsFieldWithValue()
        {
            //Arrange
            var templateId = ID.NewID;
            var targetId = ID.NewID;
            var fieldName = "StringField";

            using (Db database = new Db
            {
                new DbTemplate(templateId)
                {
                    {fieldName, ""}
                },
                new Sitecore.FakeDb.DbItem("Target", targetId, templateId),

            })
            {
                var control = new StubAbstractGlassUserControl();
                var resolver = Utilities.CreateStandardResolver();
                var context = Context.Create(resolver);
                var db = database.Database;

                Sitecore.Context.Database = db;
                control.SitecoreContext = new SitecoreContext(context);
                var sublayout = new Sublayout();
                sublayout.Parameters = string.Empty;

                sublayout.Controls.Add(control);

                //Act
                var result = control.GetRenderingParameters<GlassTestRenderingParameters>();

                //Act
                Assert.AreEqual(null, result);
            }
        }