public void CompareContractWithSavedEntity(EnergyTrading.MDM.Contracts.Sample.Location contract) { int id = int.Parse(contract.Identifiers.Where(x => x.IsMdmId).First().Identifier); var savedEntity = new DbSetRepository(new DbContextProvider(() => new SampleMappingContext())).FindOne <MDM.Location>(id); this.CompareContractWithEntityDetails(contract, savedEntity); }
protected static void Establish_context() { location = Script.LocationData.CreateContractForEntityCreation(); content = HttpContentExtensions.CreateDataContract(location); sameContent = HttpContentExtensions.CreateDataContract(location); client = new HttpClient(); }
protected override void OnSetup() { ConfigurationManager.AppSettings["MdmCaching"] = false.ToString(); base.OnSetup(); this.expected = LocationData.PostBasicEntity(); }
public void ConfirmEntitySaved(int id, EnergyTrading.MDM.Contracts.Sample.Location contract) { var savedEntity = new DbSetRepository(new DbContextProvider(() => new SampleMappingContext())).FindOne <MDM.Location>(id); contract.Identifiers.Add(new MdmId() { IsMdmId = true, Identifier = id.ToString() }); this.CompareContractWithEntityDetails(contract, savedEntity); }
public void BadSystemFails() { // Assert var start = new DateTime(1999, 1, 1); var finish = new DateTime(2020, 12, 31); var validity = new DateRange(start, finish); var system = new MDM.SourceSystem { Name = "Test" }; var locationMapping = new LocationMapping { System = system, MappingValue = "1", Validity = validity }; var list = new List<LocationMapping> { locationMapping }; var repository = new Mock<IRepository>(); repository.Setup(x => x.Queryable<LocationMapping>()).Returns(list.AsQueryable()); var badSystemIdentifier = new EnergyTrading.Mdm.Contracts.MdmId { SystemName = "Jim", Identifier = "1", StartDate = start.AddHours(-10), EndDate = start.AddHours(-5) }; var identifierValidator = new NexusIdValidator<LocationMapping>(repository.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 LocationValidator(validatorEngine.Object, repository.Object); var location = new Location { Identifiers = new EnergyTrading.Mdm.Contracts.MdmIdList { badSystemIdentifier } }; // Act var violations = new List<IRule>(); var result = validator.IsValid(location, violations); // Assert Assert.IsFalse(result, "Validator succeeded"); }
public void CompareContractWithEntityDetails(EnergyTrading.MDM.Contracts.Sample.Location contract, MDM.Location entity) { LocationComparer.Compare(contract, entity); }
private Location NewLocation(string name, int parentId) { var location = new Location(); location.Details.Name = name; location.Details.Parent = new EntityId {Identifier = new MdmId { SystemName = "Nexus", Identifier = parentId.ToString(), IsMdmId = true }}; return location; }
public void ValidLocationPasses() { // Assert var start = new DateTime(1999, 1, 1); var system = new MDM.SourceSystem { Name = "Test" }; var systemList = new List<MDM.SourceSystem> { system }; var systemRepository = new Mock<IRepository>(); var repository = new StubValidatorRepository(); 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 LocationValidator(validatorEngine.Object, repository); var location = new Location { Details = new EnergyTrading.MDM.Contracts.Sample.LocationDetails{Name = "Test"}, Identifiers = new EnergyTrading.Mdm.Contracts.MdmIdList { identifier } }; this.AddRelatedEntities(location); // Act var violations = new List<IRule>(); var result = validator.IsValid(location, violations); // Assert Assert.IsTrue(result, "Validator failed"); Assert.AreEqual(0, violations.Count, "Violation count differs"); }
public void should_not_return_a_location() { EnergyTrading.MDM.Contracts.Sample.Location returnedLocation = null; try { returnedLocation = response.Content.ReadAsDataContract <EnergyTrading.MDM.Contracts.Sample.Location>(); } catch { } Assert.IsNull(returnedLocation); }
protected static void SetAdditionalData(Location entity) { }
partial void AddRelatedEntities(EnergyTrading.MDM.Contracts.Sample.Location contract);