public void OverlapsRangeFails() { // Assert var start = new DateTime(1999, 1, 1); var finish = new DateTime(2020, 12, 31); var validity = new DateRange(start, finish); var system = new SourceSystem { Name = "Test" }; var partyMapping = new PartyMapping { System = system, MappingValue = "1", Validity = validity }; var list = new List <PartyMapping> { partyMapping }; var partyMappingRepository = new Mock <IRepository>(); partyMappingRepository.Setup(x => x.Queryable <PartyMapping>()).Returns(list.AsQueryable()); var systemList = new List <SourceSystem>(); var systemRepository = new Mock <IRepository>(); systemRepository.Setup(x => x.Queryable <MDM.SourceSystem>()).Returns(systemList.AsQueryable()); var overlapsRangeIdentifier = new EnergyTrading.Mdm.Contracts.MdmId { SystemName = "Test", Identifier = "1", StartDate = start.AddHours(10), EndDate = start.AddHours(15) }; var identifierValidator = new NexusIdValidator <PartyMapping>(partyMappingRepository.Object); var validatorEngine = new Mock <IValidatorEngine>(); validatorEngine.Setup(x => x.IsValid(It.IsAny <EnergyTrading.Mdm.Contracts.MdmId>(), It.IsAny <IList <IRule> >())) .Returns((EnergyTrading.Mdm.Contracts.MdmId x, IList <IRule> y) => identifierValidator.IsValid(x, y)); var validator = new PartyValidator(validatorEngine.Object, null); var party = new Party { Identifiers = new EnergyTrading.Mdm.Contracts.MdmIdList { overlapsRangeIdentifier } }; // Act var violations = new List <IRule>(); var result = validator.IsValid(party, violations); // Assert Assert.IsFalse(result, "Validator succeeded"); }
public void ValidPartyPasses() { // Assert var start = new DateTime(1999, 1, 1); var system = new SourceSystem { Name = "Test" }; var systemList = new List <SourceSystem> { system }; var systemRepository = new Mock <IRepository>(); systemRepository.Setup(x => x.Queryable <MDM.SourceSystem>()).Returns(systemList.AsQueryable()); var identifier = new EnergyTrading.Mdm.Contracts.MdmId { SystemName = "Test", Identifier = "1", StartDate = start.AddHours(-10), EndDate = start.AddHours(-5) }; var validatorEngine = new Mock <IValidatorEngine>(); var validator = new PartyValidator(validatorEngine.Object, null); var party = new Party { Details = new EnergyTrading.MDM.Contracts.Sample.PartyDetails { Name = "Test" }, Identifiers = new EnergyTrading.Mdm.Contracts.MdmIdList { identifier } }; // Act var violations = new List <IRule>(); var result = validator.IsValid(party, violations); // Assert Assert.IsTrue(result, "Validator failed"); Assert.AreEqual(0, violations.Count, "Violation count differs"); }