public void Map_NoConditions_MapsPartyIdToPartyName()
        {
            //Arrange
            var source = new PartyRoleProxy() { Party = new Party() { Id = 999 } };
            source.Party.AddDetails(new PartyDetails(){ Name = "999" });
            var mapper = new PartyRoleMapper();

            //Act
            var destination = mapper.Map(source);

            //Assert
            Assert.AreEqual("999", destination.Party.Name);
        }
        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.PartyRoleDetails();
            var contract        = new EnergyTrading.MDM.Contracts.Sample.PartyRole
            {
                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 PartyRoleDetails();

            var mapping = new PartyRoleMapping();

            var mappingEngine = new Mock <IMappingEngine>();
            var repository    = new Mock <IRepository>();

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

            var mapper = new PartyRoleMapper(mappingEngine.Object, repository.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 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.PartyRoleDetails();
            var contract = new EnergyTrading.MDM.Contracts.Sample.PartyRole
            {
                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 PartyRoleDetails();

            var mapping = new PartyRoleMapping();

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

            var mapper = new PartyRoleMapper(mappingEngine.Object, repository.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");
        }
Пример #4
0
        public void Map_NoConditions_MapsPartyIdToPartyName()
        {
            //Arrange
            var source = new PartyRoleProxy()
            {
                Party = new Party()
                {
                    Id = 999
                }
            };

            source.Party.AddDetails(new PartyDetails()
            {
                Name = "999"
            });
            var mapper = new PartyRoleMapper();

            //Act
            var destination = mapper.Map(source);

            //Assert
            Assert.AreEqual("999", destination.Party.Name);
        }