コード例 #1
0
        public void GetEpiserverCodeWithEntityId_ValidMappingsExist_ChannelPrefixExists_PrefixedOtherFieldValue()
        {
            var mappedField = "ItemOtherField";

            var codeMapping = new Dictionary <string, string> {
                { "Item", mappedField }
            };

            _config.Setup(x => x.EpiCodeMapping).Returns(codeMapping);

            var channelPrefix = "Prefix_";

            _config.Setup(x => x.ChannelIdPrefix).Returns(channelPrefix);

            var    id           = 123;
            var    expectedCode = "ABC";
            Entity entity       = EntityFactory.CreateItem(id);

            entity.Fields.Add(FieldFactory.CreateField(expectedCode, mappedField));

            _entityService.Setup(x => x.GetEntity(It.IsAny <int>(), It.IsAny <LoadLevel>())).Returns(entity);
            string result = _catalogCodeGenerator.GetEpiserverCode(id);

            Assert.Equal($"{channelPrefix}{expectedCode}", result);
        }
コード例 #2
0
        public void GetEpiserverCodeWithEntity_MappingsExist_NotValidForThisEntityType_EntityId()
        {
            var mappedField = "ProductOtherField";

            var codeMapping = new Dictionary <string, string>
            {
                { "Product", mappedField }
            };

            _config.Setup(x => x.EpiCodeMapping).Returns(codeMapping);

            var    id     = 123;
            Entity entity = EntityFactory.CreateItem(id);

            entity.Fields.Add(FieldFactory.CreateField("ABC", mappedField));

            string result = _catalogCodeGenerator.GetEpiserverCode(entity);

            Assert.Equal(id.ToString(), result);
        }
コード例 #3
0
        public void GetEpiserverCodeWithEntity_ValidMappingsExist_OtherFieldValue()
        {
            var mappedField = "ItemOtherField";

            var codeMapping = new Dictionary <string, string>
            {
                { "Item", mappedField }
            };

            _config.Setup(x => x.EpiCodeMapping).Returns(codeMapping);

            var    id           = 123;
            var    expectedCode = "ABC";
            Entity entity       = EntityFactory.CreateItem(id);

            entity.Fields.Add(FieldFactory.CreateField(expectedCode, mappedField));

            string result = _catalogCodeGenerator.GetEpiserverCode(entity);

            Assert.Equal(expectedCode, result);
        }
コード例 #4
0
        public void GetEpiserverCodeWithEntity_MappingsExist_NotValidForThisEntityType_ChannelPrefixExists_PrefixedEntityId()
        {
            string mappedField = "ProductOtherField";

            var codeMapping = new Dictionary <string, string> {
                { "Product", mappedField }
            };

            _config.Setup(x => x.EpiCodeMapping).Returns(codeMapping);

            string channelPrefix = "Prefix_";

            _config.Setup(x => x.ChannelIdPrefix).Returns(channelPrefix);

            int    id     = 123;
            Entity entity = EntityFactory.CreateItem(id);

            entity.Fields.Add(FieldFactory.CreateField("ABC", mappedField));

            string result = _catalogCodeGenerator.GetEpiserverCode(entity);

            Assert.Equal($"{channelPrefix}{id}", result);
        }