public void AddShouldNotThrow() { StarportBuilder builder = new StarportBuilder(Guid.NewGuid().ToString(), SolarSystems.Daibara); Starport random = builder.Build(); _repository.CommitChanges(random); }
public void BuildShouldBuildNowStarport() { string name = "McKay Port"; StarportBuilder builder = new StarportBuilder(name, SolarSystems.Daibara); Starport mcKayPort = builder.Build(); Assert.AreEqual(name, mcKayPort.Name); Assert.AreEqual(SolarSystems.Daibara, mcKayPort.System); Assert.AreEqual(1, mcKayPort.Version); }
public override void Execute(ImportStarports command) { Stopwatch stopwatch = new Stopwatch(); IDictionary <int, SolarSystemDto> solarSystems = _solarsystems.Load().ToDictionary(x => x.id); _logger.InfoFormat("Loaded solar systems {0:N} ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); IList <Station> stations = _source.Load(); _logger.InfoFormat("Loaded stations {0:N} ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); Parallel.ForEach(stations, (station, state, arg3) => { SolarSystemDto solarSystemDto; if (solarSystems.TryGetValue(station.system_id, out solarSystemDto)) { Coordinate position; if (solarSystemDto.x.HasValue && solarSystemDto.y.HasValue && solarSystemDto.z.HasValue) { position = new Coordinate(solarSystemDto.x.Value, solarSystemDto.y.Value, solarSystemDto.z.Value); } else { position = Coordinate.None; } SolarSystem system = new SolarSystem(solarSystemDto.name, position); StarportBuilder builder = new StarportBuilder(station.name, system); Starport starport = builder.Build(); _destination.CommitChanges(starport); } else { _logger.WarnFormat("Can not create station {0} solar system with id {1} not found", station.name, station.system_id); } }); _logger.InfoFormat("Saved Starports {0:N} ms", stopwatch.ElapsedMilliseconds); stopwatch.Restart(); }
public void BuildHavingNoName() { StarportBuilder builder = new StarportBuilder(" ", null); builder.Build(); }
public void BuildHavingNoSystemThrows() { StarportBuilder builder = new StarportBuilder("Name", null); builder.Build(); }