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); }
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); }
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); }
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); }