Пример #1
0
        private static void AssertTemplates(TemplatesResolverRainbow resolver)
        {
            resolver.Templates.Select(t => t.SyncItem.Name).ShouldAllBeEquivalentTo(new[]
            {
                "Animal",
                "Dog",
                "Food",
                "Nameable"
            });

            TemplateItem dogTemplate = resolver.Templates.FirstOrDefault(t => t.SyncItem.Name == "Dog");

            dogTemplate.Should().NotBeNull();
            dogTemplate.BaseTemplates.Select(b => b.SyncItem.Name).ShouldAllBeEquivalentTo(new[]
            {
                "Animal",
                "Nameable"
            });

            TemplateSection dogSection = dogTemplate.Sections.FirstOrDefault(s => s.SyncItem.Name == "Dog");

            dogSection.Should().NotBeNull();

            dogSection.Fields.Select(f => f.SyncItem.Name).ShouldAllBeEquivalentTo(new[]
            {
                "Eats",
                "Friends"
            });
            TemplateField eatsField = dogSection.Fields.FirstOrDefault(f => f.SyncItem.Name == "Eats");

            eatsField.Should().NotBeNull();
            eatsField.FieldTitle.Should().BeEquivalentTo("What food does the dog eat?");
            eatsField.FieldTypeName.Should().BeEquivalentTo("Multilist with Search");
        }
        public void ShouldResolveTemplates()
        {
            var resolver = new TemplatesResolver(
                @"..\..\..\Sitecore.CodeGenerator.Sample.Glass\Data\Serialization", new [] { "/sitecore/templates" });

            resolver.Templates.Select(t => t.SyncItem.Name).ShouldAllBeEquivalentTo(new []
            {
                "Animal",
                "Dog",
                "Food",
                "Nameable"
            });

            TemplateItem dogTemplate = resolver.Templates.FirstOrDefault(t => t.SyncItem.Name == "Dog");

            dogTemplate.Should().NotBeNull();
            dogTemplate.BaseTemplates.Select(b => b.SyncItem.Name).ShouldAllBeEquivalentTo(new []
            {
                "Animal",
                "Nameable"
            });

            TemplateSection dogSection = dogTemplate.Sections.FirstOrDefault(s => s.SyncItem.Name == "Dog");

            dogSection.Should().NotBeNull();

            dogSection.Fields.Select(f => f.SyncItem.Name).ShouldAllBeEquivalentTo(new []
            {
                "Eats",
                "Friends"
            });
            TemplateField eatsField = dogSection.Fields.FirstOrDefault(f => f.SyncItem.Name == "Eats");

            eatsField.Should().NotBeNull();
            eatsField.FieldTitle.Should().BeEquivalentTo("What food does the dog eat?");
            eatsField.FieldTypeName.Should().BeEquivalentTo("Multilist with Search");
        }