Ejemplo n.º 1
0
        public void EarlierVersionRaisesVersionConflict()
        {
            var validatorFactory = new Mock <IValidatorEngine>();
            var mappingEngine    = new Mock <IMappingEngine>();
            var repository       = new Mock <IRepository>();
            var searchCache      = new Mock <ISearchCache>();

            validatorFactory.Setup(x => x.IsValid(It.IsAny <EnergyTrading.MDM.Contracts.Sample.LegalEntity>(), It.IsAny <IList <IRule> >())).Returns(true);

            var service = new LegalEntityService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            var cd    = new EnergyTrading.MDM.Contracts.Sample.LegalEntityDetails();
            var nexus = new EnergyTrading.Mdm.Contracts.SystemData {
                StartDate = new DateTime(2012, 1, 1)
            };
            var contract = new EnergyTrading.MDM.Contracts.Sample.LegalEntity {
                Details = cd, MdmSystemData = nexus
            };

            var details = ObjectMother.Create <LegalEntityDetails>();

            details.Id = 1;
            var entity = ObjectMother.Create <LegalEntity>();

            entity.Id = 2;
            entity.AddDetails(details);

            repository.Setup(x => x.FindOne <LegalEntity>(1)).Returns(entity);

            // Act
            service.Update(1, 1, contract);
        }
        protected static void Establish_context()
        {
            legalentity = LegalEntityData.CreateContractForEntityCreation();

            content = HttpContentExtensions.CreateDataContract(legalentity);
            client = new HttpClient();
        }
Ejemplo n.º 3
0
        protected static void Establish_context()
        {
            client = new HttpClient();
            var legalentity = new EnergyTrading.MDM.Contracts.Sample.LegalEntity();

            content = HttpContentExtensions.CreateDataContract(legalentity);
        }
 protected static void Establish_context()
 {
     entity = LegalEntityData.CreateBasicEntity();
     var notAMapping = new EnergyTrading.MDM.Contracts.Sample.LegalEntity();
     content = HttpContentExtensions.CreateDataContract(notAMapping);
     client = new HttpClient();
 }
Ejemplo n.º 5
0
        protected static void Establish_context()
        {
            legalentity = LegalEntityData.CreateContractForEntityCreation();

            content = HttpContentExtensions.CreateDataContract(legalentity);
            client  = new HttpClient();
        }
Ejemplo n.º 6
0
        public void EntityNotFound()
        {
            // Arrange
            var validatorFactory = new Mock <IValidatorEngine>();
            var mappingEngine    = new Mock <IMappingEngine>();
            var repository       = new Mock <IRepository>();
            var searchCache      = new Mock <ISearchCache>();

            var service = new LegalEntityService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            var cd    = new EnergyTrading.MDM.Contracts.Sample.LegalEntityDetails();
            var nexus = new EnergyTrading.Mdm.Contracts.SystemData {
                StartDate = new DateTime(2012, 1, 1)
            };
            var contract = new EnergyTrading.MDM.Contracts.Sample.LegalEntity {
                Details = cd, MdmSystemData = nexus
            };

            validatorFactory.Setup(x => x.IsValid(It.IsAny <EnergyTrading.MDM.Contracts.Sample.LegalEntity>(), It.IsAny <IList <IRule> >())).Returns(true);

            // Act
            var response = service.Update(1, 1, contract);

            // Assert
            Assert.IsNotNull(response, "Response is null");
            Assert.IsFalse(response.IsValid, "Response is valid");
            Assert.AreEqual(ErrorType.NotFound, response.Error.Type, "ErrorType differs");
        }
        public static EnergyTrading.MDM.Contracts.Sample.LegalEntity CreateContractForEntityCreation()
        {
            var contract = new EnergyTrading.MDM.Contracts.Sample.LegalEntity();

            AddDetailsToContract(contract);
            return(contract);
        }
        protected static void Establish_context()
        {
            entity = LegalEntityData.CreateBasicEntity();
            var notAMapping = new EnergyTrading.MDM.Contracts.Sample.LegalEntity();

            content = HttpContentExtensions.CreateDataContract(notAMapping);
            client  = new HttpClient();
        }
        protected static void Establish_context()
        {
            client = new HttpClient();
            entity = LegalEntityData.CreateBasicEntity();
            var getResponse = client.Get(ServiceUrl["LegalEntity"] + entity.Id);

            updatedContract = getResponse.Content.ReadAsDataContract<EnergyTrading.MDM.Contracts.Sample.LegalEntity>();
            content = HttpContentExtensions.CreateDataContract(LegalEntityData.MakeChangeToContract(updatedContract));
        }
Ejemplo n.º 10
0
        protected static void Establish_context()
        {
            client = new HttpClient();
            entity = LegalEntityData.CreateBasicEntity();
            var getResponse = client.Get(ServiceUrl["LegalEntity"] + entity.Id);

            updatedContract = getResponse.Content.ReadAsDataContract <EnergyTrading.MDM.Contracts.Sample.LegalEntity>();
            content         = HttpContentExtensions.CreateDataContract(LegalEntityData.MakeChangeToContract(updatedContract));
        }
Ejemplo n.º 11
0
 protected static void Because_of()
 {
     using (var client = new HttpClient(ServiceUrl["LegalEntity"] +
                                        legalentity.Id))
     {
         using (HttpResponseMessage response = client.Get())
         {
             returnedLegalEntity = response.Content.ReadAsDataContract <EnergyTrading.MDM.Contracts.Sample.LegalEntity>();
         }
     }
 }
 protected static void Because_of()
 {
     using (var client = new HttpClient(ServiceUrl["LegalEntity"] +
         legalentity.Id))
     {
         using (HttpResponseMessage response = client.Get())
         {
             returnedLegalEntity = response.Content.ReadAsDataContract<EnergyTrading.MDM.Contracts.Sample.LegalEntity>();
         }
     }
 }
Ejemplo n.º 13
0
        protected static void Because_of()
        {
            asof   = Script.baseDate.AddSeconds(1);
            client =
                new HttpClient(ServiceUrl["LegalEntity"] + string.Format("{0}?as-of={1}",
                                                                         legalentity.Id.ToString(), asof.ToString(DateFormatString)));

            HttpResponseMessage response = client.Get();

            returnedLegalEntity = response.Content.ReadAsDataContract <EnergyTrading.MDM.Contracts.Sample.LegalEntity>();
        }
Ejemplo n.º 14
0
        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 MDM.SourceSystem {
                Name = "Test"
            };
            var legalentityMapping = new PartyRoleMapping {
                System = system, MappingValue = "1", Validity = validity
            };

            var list = new List <PartyRoleMapping> {
                legalentityMapping
            };
            var repository = new Mock <IRepository>();

            repository.Setup(x => x.Queryable <PartyRoleMapping>()).Returns(list.AsQueryable());

            var systemList       = new List <MDM.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 <PartyRoleMapping>(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 LegalEntityValidator(validatorEngine.Object, repository.Object);

            var legalentity = new LegalEntity {
                Identifiers = new EnergyTrading.Mdm.Contracts.MdmIdList {
                    overlapsRangeIdentifier
                }
            };

            // Act
            var violations = new List <IRule>();
            var result     = validator.IsValid(legalentity, violations);

            // Assert
            Assert.IsFalse(result, "Validator succeeded");
        }
        private static void AddDetailsToContract(EnergyTrading.MDM.Contracts.Sample.LegalEntity contract)
        {
            var entity = ObjectMother.Create <LegalEntity>();

            repository.Add(entity);
            repository.Flush();

            contract.Details = new EnergyTrading.MDM.Contracts.Sample.LegalEntityDetails()
            {
                Name  = entity.LatestDetails.Name,
                Phone = (entity.LatestDetails as LegalEntityDetails).Phone,
            };
            contract.Party = entity.Party.CreateNexusEntityId(() => "");
        }
Ejemplo n.º 16
0
        public void InvalidContractNotSaved()
        {
            // Arrange
            var validatorFactory = new Mock <IValidatorEngine>();
            var mappingEngine    = new Mock <IMappingEngine>();
            var repository       = new Mock <IRepository>();
            var searchCache      = new Mock <ISearchCache>();

            var service = new LegalEntityService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            var contract = new EnergyTrading.MDM.Contracts.Sample.LegalEntity();

            validatorFactory.Setup(x => x.IsValid(It.IsAny <object>(), It.IsAny <IList <IRule> >())).Returns(false);

            // Act
            service.Create(contract);
        }
        public void Map()
        {
            // Arrange
            var start = new DateTime(2010, 1, 1);
            var end   = DateUtility.MaxDate;
            var range = new DateRange(start, end);

            var id = new EnergyTrading.Mdm.Contracts.MdmId {
                SystemName = "Test", Identifier = "A"
            };
            var contractDetails = new EnergyTrading.MDM.Contracts.Sample.LegalEntityDetails();
            var contract        = new EnergyTrading.MDM.Contracts.Sample.LegalEntity
            {
                Identifiers = new EnergyTrading.Mdm.Contracts.MdmIdList {
                    id
                },
                Details       = contractDetails,
                MdmSystemData = new EnergyTrading.Mdm.Contracts.SystemData {
                    StartDate = start, EndDate = end
                },
                Party = ObjectMother.Create <Party>().CreateNexusEntityId(() => ""),
            };

            // NB Don't assign validity here, want to prove SUT sets it
            var details = new LegalEntityDetails();

            var mapping = new PartyRoleMapping();

            var mappingEngine = new Mock <IMappingEngine>();

            mappingEngine.Setup(x => x.Map <EnergyTrading.Mdm.Contracts.MdmId, PartyRoleMapping>(id)).Returns(mapping);
            mappingEngine.Setup(x => x.Map <EnergyTrading.MDM.Contracts.Sample.LegalEntityDetails, LegalEntityDetails>(contractDetails)).Returns(details);
            var repository = new Mock <IRepository>();

            repository.Setup(x => x.FindOne <Party>(int.Parse(contract.Party.Identifier.Identifier))).Returns(ObjectMother.Create <Party>());

            var mapper = new LegalEntityMapper(repository.Object, mappingEngine.Object);

            // Act
            var candidate = mapper.Map(contract);

            // Assert
            //Assert.AreEqual(1, candidate.Details.Count, "Detail count differs");
            Assert.AreEqual(1, candidate.Mappings.Count, "Mapping count differs");
            Check(range, details.Validity, "Validity differs");
        }
        public void InvalidContractNotSaved()
        {
            // Arrange
            var validatorFactory = new Mock<IValidatorEngine>();
            var mappingEngine = new Mock<IMappingEngine>();
            var repository = new Mock<IRepository>();
            var searchCache = new Mock<ISearchCache>();

            var service = new LegalEntityService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            var contract = new EnergyTrading.MDM.Contracts.Sample.LegalEntity();

            validatorFactory.Setup(x => x.IsValid(It.IsAny<object>(), It.IsAny<IList<IRule>>())).Returns(false);

            // Act
            service.Create(contract);
        }
Ejemplo n.º 19
0
        public void ValidLegalEntityPasses()
        {
            // 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 LegalEntityValidator(validatorEngine.Object, repository);

            var legalentity = new LegalEntity {
                Identifiers = new EnergyTrading.Mdm.Contracts.MdmIdList {
                    identifier
                }
            };

            this.AddRelatedEntities(legalentity);

            // Act
            var violations = new List <IRule>();
            var result     = validator.IsValid(legalentity, violations);

            // Assert
            Assert.IsTrue(result, "Validator failed");
            Assert.AreEqual(0, violations.Count, "Violation count differs");
        }
        public void Map()
        {
            // Arrange
            var start = new DateTime(2010, 1, 1);
            var end = DateUtility.MaxDate;
            var range = new DateRange(start, end);

            var id = new EnergyTrading.Mdm.Contracts.MdmId { SystemName = "Test", Identifier = "A" };
            var contractDetails = new EnergyTrading.MDM.Contracts.Sample.LegalEntityDetails();
            var contract = new EnergyTrading.MDM.Contracts.Sample.LegalEntity
            {
                Identifiers = new EnergyTrading.Mdm.Contracts.MdmIdList { id },
                Details = contractDetails,
                MdmSystemData = new EnergyTrading.Mdm.Contracts.SystemData { StartDate = start, EndDate = end },
                Party = ObjectMother.Create<Party>().CreateNexusEntityId(() => ""),
            };

            // NB Don't assign validity here, want to prove SUT sets it
            var details = new LegalEntityDetails();

            var mapping = new PartyRoleMapping();

            var mappingEngine = new Mock<IMappingEngine>();
            mappingEngine.Setup(x => x.Map<EnergyTrading.Mdm.Contracts.MdmId, PartyRoleMapping>(id)).Returns(mapping);
            mappingEngine.Setup(x => x.Map<EnergyTrading.MDM.Contracts.Sample.LegalEntityDetails, LegalEntityDetails>(contractDetails)).Returns(details);
            var repository = new Mock<IRepository>();
            repository.Setup(x => x.FindOne<Party>(int.Parse(contract.Party.Identifier.Identifier))).Returns(ObjectMother.Create<Party>());

            var mapper = new LegalEntityMapper(repository.Object, mappingEngine.Object);

            // Act
            var candidate = mapper.Map(contract);

            // Assert
            //Assert.AreEqual(1, candidate.Details.Count, "Detail count differs");
            Assert.AreEqual(1, candidate.Mappings.Count, "Mapping count differs");
            Check(range, details.Validity, "Validity differs");
        }
        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 legalentityMapping = new PartyRoleMapping { System = system, MappingValue = "1", Validity = validity };

            var list = new List<PartyRoleMapping> { legalentityMapping };
            var repository = new Mock<IRepository>();
            repository.Setup(x => x.Queryable<PartyRoleMapping>()).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<PartyRoleMapping>(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 LegalEntityValidator(validatorEngine.Object, repository.Object);

            var legalentity = new LegalEntity { Identifiers = new EnergyTrading.Mdm.Contracts.MdmIdList { badSystemIdentifier } };

            // Act
            var violations = new List<IRule>();
            var result = validator.IsValid(legalentity, violations);

            // Assert
            Assert.IsFalse(result, "Validator succeeded");
        }
        public void ValidContractIsSaved()
        {
            // Arrange
            var validatorFactory = new Mock<IValidatorEngine>();
            var mappingEngine = new Mock<IMappingEngine>();
            var repository = new Mock<IRepository>();
            var searchCache = new Mock<ISearchCache>();

            var service = new LegalEntityService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            var legalentity = new LegalEntity();
            var contract = new EnergyTrading.MDM.Contracts.Sample.LegalEntity();

            validatorFactory.Setup(x => x.IsValid(It.IsAny<EnergyTrading.MDM.Contracts.Sample.LegalEntity>(), It.IsAny<IList<IRule>>())).Returns(true);
            mappingEngine.Setup(x => x.Map<EnergyTrading.MDM.Contracts.Sample.LegalEntity, LegalEntity>(contract)).Returns(legalentity);

            // Act
            var expected = service.Create(contract);

            // Assert
            Assert.AreSame(expected, legalentity, "LegalEntity differs");
            repository.Verify(x => x.Add(legalentity));
            repository.Verify(x => x.Flush());
        }
Ejemplo n.º 23
0
        public void ValidContractIsSaved()
        {
            // Arrange
            var validatorFactory = new Mock <IValidatorEngine>();
            var mappingEngine    = new Mock <IMappingEngine>();
            var repository       = new Mock <IRepository>();
            var searchCache      = new Mock <ISearchCache>();

            var service = new LegalEntityService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            var legalentity = new LegalEntity();
            var contract    = new EnergyTrading.MDM.Contracts.Sample.LegalEntity();

            validatorFactory.Setup(x => x.IsValid(It.IsAny <EnergyTrading.MDM.Contracts.Sample.LegalEntity>(), It.IsAny <IList <IRule> >())).Returns(true);
            mappingEngine.Setup(x => x.Map <EnergyTrading.MDM.Contracts.Sample.LegalEntity, LegalEntity>(contract)).Returns(legalentity);

            // Act
            var expected = service.Create(contract);

            // Assert
            Assert.AreSame(expected, legalentity, "LegalEntity differs");
            repository.Verify(x => x.Add(legalentity));
            repository.Verify(x => x.Flush());
        }
        public static EnergyTrading.MDM.Contracts.Sample.LegalEntity MakeChangeToContract(EnergyTrading.MDM.Contracts.Sample.LegalEntity currentContract)
        {
            var entity = ObjectMother.Create <LegalEntity>();

            repository.Add(entity);
            repository.Flush();

            currentContract.Details = new EnergyTrading.MDM.Contracts.Sample.LegalEntityDetails()
            {
                Name  = entity.LatestDetails.Name,
                Phone = (entity.LatestDetails as LegalEntityDetails).Phone,
                Fax   = (entity.LatestDetails as LegalEntityDetails).Fax,
            };

            currentContract.MdmSystemData.StartDate = currentContract.MdmSystemData.StartDate.Value.AddDays(2);
            return(currentContract);
        }
 protected static void Establish_context()
 {
     client = new HttpClient();
     var legalentity = new EnergyTrading.MDM.Contracts.Sample.LegalEntity();
     content = HttpContentExtensions.CreateDataContract(legalentity);
 }
        protected static void Because_of()
        {
            asof = Script.baseDate.AddSeconds(1);
            client =
                new HttpClient(ServiceUrl["LegalEntity"] + string.Format("{0}?as-of={1}",
                    legalentity.Id.ToString(), asof.ToString(DateFormatString)));

            HttpResponseMessage response = client.Get();
            returnedLegalEntity = response.Content.ReadAsDataContract<EnergyTrading.MDM.Contracts.Sample.LegalEntity>();
        }
        public void ValidLegalEntityPasses()
        {
            // 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 LegalEntityValidator(validatorEngine.Object, repository);

            var legalentity = new LegalEntity { Identifiers = new EnergyTrading.Mdm.Contracts.MdmIdList { identifier } };
            this.AddRelatedEntities(legalentity);

            // Act
            var violations = new List<IRule>();
            var result = validator.IsValid(legalentity, violations);

            // Assert
            Assert.IsTrue(result, "Validator failed");
            Assert.AreEqual(0, violations.Count, "Violation count differs");
        }
Ejemplo n.º 28
0
        public void ValidDetailsSaved()
        {
            var validatorFactory = new Mock <IValidatorEngine>();
            var mappingEngine    = new Mock <IMappingEngine>();
            var repository       = new Mock <IRepository>();
            var searchCache      = new Mock <ISearchCache>();

            // Contract
            var cd    = new EnergyTrading.MDM.Contracts.Sample.LegalEntityDetails();
            var nexus = new EnergyTrading.Mdm.Contracts.SystemData {
                StartDate = new DateTime(2012, 1, 1)
            };
            var identifier = new EnergyTrading.Mdm.Contracts.MdmId {
                SystemName = "Test", Identifier = "A"
            };
            var contract = new EnergyTrading.MDM.Contracts.Sample.LegalEntity {
                Details = cd, MdmSystemData = nexus
            };

            contract.Identifiers.Add(identifier);

            // Domain
            var system = new SourceSystem {
                Name = "Test"
            };
            var mapping = new PartyRoleMapping {
                System = system, MappingValue = "A"
            };
            var d1 = new LegalEntityDetails {
                Id = 1, Name = "LE 1", Timestamp = 74UL.GetVersionByteArray()
            };
            var entity = new LegalEntity {
                Party = new Party {
                    Id = 999
                }
            };

            entity.AddDetails(d1);

            var d2 = new LegalEntityDetails {
                Name = "LE 1"
            };
            var range = new DateRange(new DateTime(2012, 1, 1), DateTime.MaxValue);

            validatorFactory.Setup(x => x.IsValid(It.IsAny <CreateMappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true);
            validatorFactory.Setup(x => x.IsValid(It.IsAny <EnergyTrading.MDM.Contracts.Sample.LegalEntity>(), It.IsAny <IList <IRule> >())).Returns(true);

            repository.Setup(x => x.FindOne <LegalEntity>(1)).Returns(entity);

            mappingEngine.Setup(x => x.Map <EnergyTrading.MDM.Contracts.Sample.LegalEntityDetails, LegalEntityDetails>(cd)).Returns(d2);
            mappingEngine.Setup(x => x.Map <EnergyTrading.Mdm.Contracts.SystemData, DateRange>(nexus)).Returns(range);
            mappingEngine.Setup(x => x.Map <EnergyTrading.Mdm.Contracts.MdmId, PartyRoleMapping>(identifier)).Returns(mapping);

            var service = new LegalEntityService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            // Act
            service.Update(1, 74, contract);

            // Assert
            Assert.AreEqual(2, entity.Details.Count, "Details count differs");
            Assert.AreEqual(1, entity.Mappings.Count, "Mapping count differs");
            repository.Verify(x => x.Save(entity));
            repository.Verify(x => x.Flush());
        }
 public static EnergyTrading.MDM.Contracts.Sample.LegalEntity CreateContractForEntityCreation()
 {
     var contract = new EnergyTrading.MDM.Contracts.Sample.LegalEntity();
     AddDetailsToContract(contract);
     return contract;
 }