public void MarketDescriptionDTOMappingTest() { var msg = RMF.GetDescMarket(); var dto = new MarketDescriptionDTO(msg); Assert.AreEqual(msg.id, dto.Id); Assert.AreEqual(msg.name, dto.Name); Assert.AreEqual(msg.description, dto.Description); //Assert.AreEqual(msg.variant, dto.Variant); //TODO: check if variant is missing in dto? Assert.AreEqual(msg.mappings.Length, dto.Mappings.Count()); Assert.AreEqual(msg.outcomes.Length, dto.Outcomes.Count()); Assert.AreEqual(msg.specifiers.Length, dto.Specifiers.Count()); for (var i = 0; i < msg.mappings.Length; i++) { ValidateMapping(msg.mappings[i], dto.Mappings.ToArray()[i]); } for (var i = 0; i < msg.outcomes.Length; i++) { ValidateOutcome(msg.outcomes[i], dto.Outcomes.ToArray()[i]); } for (var i = 0; i < msg.specifiers.Length; i++) { ValidateSpecifier(msg.specifiers[i], dto.Specifiers.ToArray()[i]); } }
public void MarketDescriptionMergeTest() { var msg1 = RMF.GetDescMarket(10); var msg2 = RMF.GetDescMarket(msg1); var ci = MarketDescriptionCacheItem.Build(new MarketDescriptionDTO(msg1), _mappingValidatorFactory, FirstCulture, "test"); ci.Merge(new MarketDescriptionDTO(msg2), SecondCulture); Assert.AreEqual(msg1.id, ci.Id); Assert.AreEqual(msg1.name, ci.GetName(FirstCulture)); Assert.AreEqual(msg1.description, ci.GetDescription(FirstCulture)); Assert.AreEqual(msg1.variant, ci.Variant); Assert.AreEqual(msg1.mappings.Length, ci.Mappings.Count()); Assert.AreEqual(msg1.outcomes.Length, ci.Outcomes.Count()); Assert.AreEqual(msg1.specifiers.Length, ci.Specifiers.Count()); for (var i = 0; i < msg1.mappings.Length; i++) { ValidateMapping(msg1.mappings[i], ci.Mappings.ToArray()[i]); } for (var i = 0; i < msg1.outcomes.Length; i++) { ValidateOutcome(msg1.outcomes[i], ci.Outcomes.ToArray()[i], FirstCulture); } for (var i = 0; i < msg1.specifiers.Length; i++) { ValidateSpecifier(msg1.specifiers[i], ci.Specifiers.ToArray()[i]); } Assert.AreEqual(msg2.id, ci.Id); Assert.AreEqual(msg2.name, ci.GetName(SecondCulture)); Assert.AreEqual(msg2.description, ci.GetDescription(SecondCulture)); Assert.AreEqual(msg2.variant, ci.Variant); // TODO: variant is not overriding Assert.AreEqual(msg2.mappings.Length, ci.Mappings.Count()); Assert.AreEqual(msg2.outcomes.Length, ci.Outcomes.Count()); Assert.AreEqual(msg2.specifiers.Length, ci.Specifiers.Count()); for (var i = 0; i < msg2.mappings.Length; i++) { ValidateMapping(msg2.mappings[i], ci.Mappings.ToArray()[i]); } for (var i = 0; i < msg2.outcomes.Length; i++) { ValidateOutcome(msg2.outcomes[i], ci.Outcomes.ToArray()[i], SecondCulture); } for (var i = 0; i < msg2.specifiers.Length; i++) { ValidateSpecifier(msg2.specifiers[i], ci.Specifiers.ToArray()[i]); } Assert.AreNotEqual(ci.GetName(FirstCulture), ci.GetName(SecondCulture)); Assert.AreNotEqual(ci.GetDescription(FirstCulture), ci.GetDescription(SecondCulture)); Assert.IsTrue(ci.HasTranslationsFor(FirstCulture)); Assert.IsTrue(ci.HasTranslationsFor(SecondCulture)); Assert.IsFalse(ci.HasTranslationsFor(new CultureInfo("es"))); }