Exemplo n.º 1
0
        public static Guid GetTemplateIdFromType(this Type t)
        {
            SitecoreTypeAttribute sitecoreTypeAttribute = (SitecoreTypeAttribute)t.GetCustomAttribute(typeof(SitecoreTypeAttribute), true);
            Guid templateId;

            if (Guid.TryParse(sitecoreTypeAttribute.TemplateId, out templateId))
            {
                return(templateId);
            }
            return(Guid.Empty);
        }
Exemplo n.º 2
0
        public void Configure_ConfigurationIsIncorrectType_ExceptionThrown()
        {
            //Assign
            var attr   = new SitecoreTypeAttribute();
            var config = Substitute.For <AbstractTypeConfiguration>();
            var type   = typeof(StubClass);

            var templateIdExpected = Guid.Empty;
            var branchIdExptected  = Guid.Empty;

            //Act
            attr.Configure(type, config);

            //Assert
        }
Exemplo n.º 3
0
        public void Configure_AttributeHasInvalidBranchId_ExceptionThrown()
        {
            //Assign
            var attr = new SitecoreTypeAttribute();
            var type = typeof(StubClass);

            var templateIdExpected = Guid.Empty;
            var branchIdExptected  = Guid.Empty;

            attr.BranchId = "not a guid";

            //Act
            var config = attr.Configure(type) as SitecoreTypeConfiguration;

            //Assert
        }
Exemplo n.º 4
0
        public void Configure_ConfigurationIsOfCorrectType_NoExceptionThrown()
        {
            //Assign
            var attr = new SitecoreTypeAttribute();
            var type = typeof(StubClass);

            var templateIdExpected = Guid.Empty;
            var branchIdExptected  = Guid.Empty;

            //Act
            var config = attr.Configure(type) as SitecoreTypeConfiguration;

            //Assert
            Assert.AreEqual(type, config.Type);
            Assert.AreEqual(new ID(templateIdExpected), config.TemplateId);
            Assert.AreEqual(new ID(branchIdExptected), config.BranchId);
        }
Exemplo n.º 5
0
        public void Configure_AttributeHasBranchId_BranchIdSetOnConfig()
        {
            //Assign
            var attr = new SitecoreTypeAttribute();
            var type = typeof(StubClass);

            var templateIdExpected = Guid.Empty;
            var branchIdExptected  = new Guid();

            attr.BranchId = branchIdExptected.ToString();

            //Act
            var config = attr.Configure(type) as SitecoreTypeConfiguration;

            //Assert
            Assert.AreEqual(type, config.Type);
            Assert.AreEqual(new ID(templateIdExpected), config.TemplateId);
            Assert.AreEqual(new ID(branchIdExptected), config.BranchId);
        }