Exemplo n.º 1
0
        public async Task Create(Airport airport)
        {
            var airportAggregate = new Domain.Airport(Guid.NewGuid());

            airportAggregate.SetIata(airport.Iata);
            if (airport.Lon.HasValue && airport.Lat.HasValue)
            {
                airportAggregate.SetCoordinates(airport.Lat.Value, airport.Lon.Value);
            }

            if (airport.Status)
            {
                airportAggregate.Enable();
            }
            else
            {
                airportAggregate.Disable();
            }

            airportAggregate.SetLocation(airport.Continent, airport.Iso);
            airportAggregate.SetName(airport.Name);
            airportAggregate.SetSize(airport.Size);
            airportAggregate.SetType(airport.Type);

            await _airportRepository.Save(airportAggregate);
        }
Exemplo n.º 2
0
        public void SetCoordinates()
        {
            var airport = new Domain.Airport(Guid.NewGuid());

            airport.SetCoordinates(10.2, 32.4);

            Assert.Equal(10.2, airport.State.Lat);
            Assert.Equal(32.4, airport.State.Lon);
        }
Exemplo n.º 3
0
        public void SetCoordinatesOutOfRange(double latitude, double longitude)
        {
            var airport = new Domain.Airport(Guid.NewGuid());

            Assert.Throws <ArgumentOutOfRangeException>(() => airport.SetCoordinates(latitude, longitude));
        }