Beispiel #1
0
        public void UnmappedTemplateForContext()
        {
            using (ShimsContext.Create())
            {
                var testItem = CreateTestItem();
                var contextProvider = new Mock<IContextProvider>();

                contextProvider.Setup(c => c.PageContextItem).Returns(testItem);

                var itemFactory = new ItemFactory(contextProvider.Object);
                var wrappedItem = itemFactory.GetContextItem<IScUnmappedTemplate>();
            }
        }
Beispiel #2
0
        public void CorrectInheritedTemplatesForRenderingContext()
        {
            using (ShimsContext.Create())
            {
                var tId = new Guid("{02F5002C-325E-4E5A-9C93-A97724ED3400}");
                var testItem = CreateTestItem(templateId: tId);

                Template templateItem = new ShimTemplate()
                {
                    DescendsFromID = id => true,
                };
                ShimTemplateManager.GetTemplateItem = id =>
                {
                    return templateItem;
                };

                var contextProvider = new Mock<IContextProvider>();

                contextProvider.Setup(c => c.PageContextItem).Returns(testItem);
                contextProvider.Setup(c => c.RenderingContextItem).Returns(testItem);
                contextProvider.Setup(c => c.RenderingItem).Returns(testItem);
                contextProvider.Setup(c => c.RenderingParameters).Returns(new Dictionary<string, string>());

                var itemFactory = new ItemFactory(contextProvider.Object);
                var wrappedItem = itemFactory.GetContextItem<IScTemplate>();

                Assert.IsNotNull(wrappedItem);
            }
        }
Beispiel #3
0
        public void IncorrectTemplateForContext()
        {
            using (ShimsContext.Create())
            {
                var templateId = new Guid("{AF49395C-74BB-4ACF-8E01-F2B5BEECA8FE}");
                var testItem = CreateTestItem(templateId: templateId);
                var contextProvider = new Mock<IContextProvider>();

                contextProvider.Setup(c => c.PageContextItem).Returns(testItem);

                var itemFactory = new ItemFactory(contextProvider.Object);
                var wrappedItem = itemFactory.GetContextItem<IScTemplate>();

                Assert.IsNull(wrappedItem);
            }
        }
Beispiel #4
0
        public void CorrectInheritedTemplateForContext()
        {
            using (ShimsContext.Create())
            {
                var testItem = CreateTestItem();

                Template templateItem = new ShimTemplate()
                {
                    DescendsFromID = id => true,
                };
                ShimTemplateManager.GetTemplateItem = id =>
                {
                    return templateItem;
                };

                var contextProvider = new Mock<IContextProvider>();

                contextProvider.Setup(c => c.PageContextItem).Returns(testItem);

                var itemFactory = new ItemFactory(contextProvider.Object);
                var wrappedItem = itemFactory.GetContextItem<IScBaseTemplate>();

                Assert.IsNotNull(wrappedItem);
            }
        }
Beispiel #5
-1
        public void CorrectDirectTemplateForContext()
        {
            using (ShimsContext.Create())
            {
                var templateId = new Guid("{02F5002C-325E-4E5A-9C93-A97724ED3400}");
                var testItem = CreateTestItem(templateId: templateId);
                var contextProvider = new Mock<IContextProvider>();

                contextProvider.Setup(c => c.PageContextItem).Returns(testItem);

                var itemFactory = new ItemFactory(contextProvider.Object);
                var wrappedItem = itemFactory.GetContextItem<IScTemplate>();

                Assert.IsNotNull(wrappedItem);
            }
        }