Ejemplo n.º 1
0
        public void WithFullName_WhenCalled_ConfiguresTemplateEngineToFindTemplateByFullName(string fullName)
        {
            FakeTemplate template = new FakeTemplate().WithFullName(fullName);

            var foundByFullName = template.TemplateEngine.GetTemplate(fullName);

            foundByFullName.Should().Be(template.ToSitecoreTemplate());
        }
Ejemplo n.º 2
0
        public void Constructor_WhenCalledWithFakeTemplate_SetsSectionTemplateToParent(ID templateId)
        {
            var template = new FakeTemplate(templateId: templateId);

            TemplateSection section = new FakeTemplateSection(template);

            section.Template.Should().Be(template.ToSitecoreTemplate());
        }
Ejemplo n.º 3
0
        public void AddField_WhenCalled_AddsSection(string fieldName, string sectionName, ID fieldId)
        {
            var fakeTemplate = new FakeTemplate();

            fakeTemplate.AddField(sectionName, fieldName, fieldId);

            Template template = fakeTemplate.ToSitecoreTemplate();

            template.GetSections().Should().ContainSingle(section => section.Name == sectionName);
        }
Ejemplo n.º 4
0
        public void AddField_WhenCalled_AddsFieldToTemplate(string fieldName, string sectionName, ID fieldId)
        {
            var fakeTemplate = new FakeTemplate();

            fakeTemplate.AddField(sectionName, fieldName, fieldId);

            Template template = fakeTemplate.ToSitecoreTemplate();

            template.GetFields().Should().ContainSingle(field => field.ID == fieldId);
        }
Ejemplo n.º 5
0
        public void AddSection_WhenCalled_AddsSectionToParentTemplate(string name, ID id)
        {
            var fakeTemplate = new FakeTemplate();

            fakeTemplate.AddSection(name, id);

            Template template = fakeTemplate.ToSitecoreTemplate();

            template.GetSections().Should().ContainSingle();
        }
Ejemplo n.º 6
0
        public void AddField_WhenCalledTwoTimesForSameSection_CreatesOnlyOneSection(string unoField, string dosField, ID unoFieldId, ID dosFieldId, string sectionName)
        {
            var fakeTemplate = new FakeTemplate();

            fakeTemplate.AddField(sectionName, unoField, unoFieldId);
            fakeTemplate.AddField(sectionName, dosField, dosFieldId);

            Template template = fakeTemplate.ToSitecoreTemplate();

            template.GetSections().Should().ContainSingle();
        }
Ejemplo n.º 7
0
        public void AddSection_WhenCalled_AllowsGetSectionToBeFoundById(string name, ID id)
        {
            var             fakeTemplate = new FakeTemplate();
            TemplateSection section      = fakeTemplate.AddSection(name, id);

            Template template = fakeTemplate.ToSitecoreTemplate();

            var foundSection = template.GetSection(id);

            foundSection.Should().Be(section);
        }
Ejemplo n.º 8
0
        public void AddField_WhenCalledForDifferentSections_AddsFieldsToDistinctSections(string unoField, string dosField, ID unoFieldId, ID dosFieldId, string unoSectionName, string dosSectionName)
        {
            var fakeTemplate = new FakeTemplate();

            fakeTemplate.AddField(unoSectionName, unoField, unoFieldId);
            fakeTemplate.AddField(dosSectionName, dosField, dosFieldId);

            Template template = fakeTemplate.ToSitecoreTemplate();

            template.GetSections()
            .Should()
            .ContainSingle(section => section.GetField(unoFieldId) != null, nameof(unoSectionName))
            .And
            .ContainSingle(section => section.GetField(dosFieldId) != null, nameof(dosSectionName));
        }
Ejemplo n.º 9
0
        public void AddField_WhenCalledTwoTimesForSameSection_AddsToSameSection(string unoField, string dosField, ID unoFieldId, ID dosFieldId, string sectionName)
        {
            var fakeTemplate = new FakeTemplate();

            fakeTemplate.AddField(sectionName, unoField, unoFieldId);
            fakeTemplate.AddField(sectionName, dosField, dosFieldId);

            Template template = fakeTemplate.ToSitecoreTemplate();

            var section = template.GetSection(sectionName);

            section.GetFields()
            .Should().HaveCount(2)
            .And.ContainSingle(f => f.ID == unoFieldId, nameof(unoFieldId))
            .And.ContainSingle(f => f.ID == dosFieldId, nameof(dosFieldId));
        }