Ejemplo n.º 1
0
        public void TestMapByCountry()
        {
            var locationMapper = new LocationMapper(_locationQuery);

            var locationRef = locationMapper.Map("Australia", null, null, null);

            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.IsTrue(locationRef.IsCountry);

            locationRef = locationMapper.Map("United Kingdom", null, null, null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.IsTrue(locationRef.IsCountry);

            locationRef = locationMapper.Map("United States", null, null, null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.IsTrue(locationRef.IsCountry);

            try
            {
                locationMapper.Map("Kazakhstan", null, null, null);
                Assert.Fail();
            }
            catch (ServiceEndUserException ex)
            {
                Assert.AreEqual("Invalid country.", ex.Message);
            }
        }
Ejemplo n.º 2
0
        public void TestMapByCountryLocationArea()
        {
            var locationMapper = new LocationMapper(_locationQuery);

            // Ballarat
            LocationReference locationRef = locationMapper.Map("Australia", "VIC Other", "Ballarat", null);

            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("VIC", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("Ballarat", locationRef.NamedLocation.Name);

            // Albury Wodonga
            locationRef = locationMapper.Map("Australia", "NSW Other", "Albury Wodonga", null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("NSW", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("Albury", locationRef.NamedLocation.Name);

            // Alice Springs
            locationRef = locationMapper.Map("Australia", "NT Other", "Alice Springs", null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("NT", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("Alice Springs", locationRef.NamedLocation.Name);

            // Auckland Inner
            locationRef = locationMapper.Map("New Zealand", "Auckland", "Auckland Inner", null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("New Zealand", locationRef.Country.Name);

            // Sydney Inner
            locationRef = locationMapper.Map("Australia", "Sydney", "Sydney Inner", null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("NSW", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("Sydney", locationRef.NamedLocation.Name);
        }
Ejemplo n.º 3
0
        public void LocalityTest()
        {
            var bentleigh = _locationQuery.ResolveLocation(_australia, "3204");
            var mapped    = _mapper.Map(bentleigh);

            Assert.AreEqual("20-168-1", mapped.id);
        }
Ejemplo n.º 4
0
        public void WhenLongitude_ShouldMapLongitude()
        {
            // Act
            var actual = _sut.Map(_itemToMap);

            // Assert
            actual.Longitude.Should().Be(_itemToMap.Longitude);
        }
Ejemplo n.º 5
0
        public void TestMapByPostcode()
        {
            var locationMapper = new LocationMapper(_locationQuery);

            LocationReference locationRef = locationMapper.Map("Australia", null, null, "3182");

            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("VIC", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("3182", locationRef.NamedLocation.Name);

            locationRef = locationMapper.Map("Australia", "Melbourne", null, "3182");
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("VIC", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("3182", locationRef.NamedLocation.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.LocationDetails();
            var contract = new EnergyTrading.MDM.Contracts.Sample.Location
            {
                Identifiers = new EnergyTrading.Mdm.Contracts.MdmIdList { id },
                Details = contractDetails,
                MdmSystemData = new EnergyTrading.Mdm.Contracts.SystemData { StartDate = start, EndDate = end }
            };

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

            var mapping = new LocationMapping();

            var mappingEngine = new Mock<IMappingEngine>();
            mappingEngine.Setup(x => x.Map<EnergyTrading.Mdm.Contracts.MdmId, LocationMapping>(id)).Returns(mapping);
            mappingEngine.Setup(x => x.Map<EnergyTrading.MDM.Contracts.Sample.LocationDetails, Location>(contractDetails)).Returns(details);

            var mapper = new LocationMapper(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");
        }
Ejemplo n.º 7
0
        public async Task <List <LocationDto> > GetAllLocations()
        {
            if (await _dbContext.Locations.CountAsync() == 0)
            {
                await AddDefaultLocations();
            }
            List <Location> locations = await _dbContext.Locations.ToListAsync();

            return(_locationMapper.Map(locations));
        }
Ejemplo n.º 8
0
        public void TestMapByCountryLocation()
        {
            var locationMapper = new LocationMapper(_locationQuery);

            // Sydney
            var locationRef = locationMapper.Map("Australia", "Sydney", null, null);

            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("NSW", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("Sydney", locationRef.NamedLocation.Name);

            // Gold Coast
            locationRef = locationMapper.Map("Australia", "Gold Coast", null, null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("QLD", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("Gold Coast", locationRef.NamedLocation.Name);

            // NSW Other
            locationRef = locationMapper.Map("Australia", "NSW Other", null, null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("NSW", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("New South Wales", locationRef.NamedLocation.Name);

            // VIC Other
            locationRef = locationMapper.Map("Australia", "VIC Other", null, null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("VIC", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("Victoria", locationRef.NamedLocation.Name);

            // TAS Other
            locationRef = locationMapper.Map("Australia", "TAS Other", null, null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("TAS", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("Tasmania", locationRef.NamedLocation.Name);

            // WA Other
            locationRef = locationMapper.Map("Australia", "WA Other", null, null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("WA", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("Western Australia", locationRef.NamedLocation.Name);

            // SA Other
            locationRef = locationMapper.Map("Australia", "SA Other", null, null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("SA", locationRef.CountrySubdivision.ShortName);
            Assert.AreEqual("South Australia", locationRef.NamedLocation.Name);

            // Auckland
            locationRef = locationMapper.Map("New Zealand", "Auckland", null, null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("New Zealand", locationRef.Country.Name);

            // Wellington
            locationRef = locationMapper.Map("New Zealand", "Wellington", null, null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("New Zealand", locationRef.Country.Name);

            // North Island Other
            locationRef = locationMapper.Map("New Zealand", "North Island Other", null, null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("New Zealand", locationRef.Country.Name);

            // UK Other
            locationRef = locationMapper.Map("United Kingdom", "UK Other", null, null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("United Kingdom", locationRef.Country.Name);

            // Perth
            locationRef = locationMapper.Map("Australia", "Western Australia", "Perth", null);
            Assert.IsTrue(locationRef.IsFullyResolved);
            Assert.AreEqual("Australia", locationRef.Country.Name);
            Assert.AreEqual("Perth", locationRef.NamedLocation.Name);
        }