Exemple #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");
        }
Exemple #2
0
        public void Constructor_WhenCalledWithoutValues_SetsNameAndId()
        {
            var fakeField = new FakeTemplateField();

            fakeField.Builder.Should().NotBeNull();
            TemplateField field = fakeField;

            field.Should().NotBeNull();
            field.Name.Should().Be("fakeField");
            field.ID.Should().NotBeNull();
        }
        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");
        }