public void TestSqlRepositoryPresent()
 {
     IEDDIStarSystemRepository starSystemRepository = new EDDIStarSystemSqLiteRepository();
     EDDIStarSystem DBData = starSystemRepository.GetEDDIStarSystem("Nangkano");
     Assert.IsNotNull(DBData);
     Assert.AreEqual("Nangkano", DBData.StarSystem.Name);
 }
        /// <summary>
        /// Obtain the EDSM log and sync it with the local datastore
        /// </summary>
        private void edsmObtainLogClicked(object sender, RoutedEventArgs e)
        {
            IEDDIStarSystemRepository starSystemRepository = new EDDIStarSystemSqLiteRepository();
            StarMapConfiguration starMapConfiguration = StarMapConfiguration.FromFile();

            string commanderName;
            if (String.IsNullOrEmpty(starMapConfiguration.commanderName))
            {
                // Fetch the commander name from the companion app
                CompanionAppService companionAppService = new CompanionAppService(eddiConfiguration.Debug);
                Commander cmdr = companionAppService.Profile();
                if (cmdr != null && cmdr.Name != null)
                {
                    commanderName = cmdr.Name;
                }
                else
                {
                    edsmFetchLogsButton.IsEnabled = false;
                    edsmFetchLogsButton.Content = "Companion app not configured and no name supplied; cannot obtain logs";
                    return;
                }
            }
            else
            {
                commanderName = starMapConfiguration.commanderName;
            }

            edsmFetchLogsButton.IsEnabled = false;
            edsmFetchLogsButton.Content = "Obtaining log...";

            StarMapService starMapService = new StarMapService(starMapConfiguration.apiKey, commanderName);

            Dictionary<string, StarMapLogInfo> systems = starMapService.getStarMapLog();
            foreach (string system in systems.Keys)
            {
                EDDIStarSystem CurrentStarSystemData = starSystemRepository.GetEDDIStarSystem(system);
                if (CurrentStarSystemData == null)
                {
                    // We have no record of this system; set it up
                    CurrentStarSystemData = new EDDIStarSystem();
                    CurrentStarSystemData.Name = system;
                    // Due to the potential large number of systems being imported we don't pull individual system data at this time
                }
                CurrentStarSystemData.TotalVisits = systems[system].visits;
                CurrentStarSystemData.LastVisit = systems[system].lastVisit;
                CurrentStarSystemData.PreviousVisit = systems[system].previousVisit;
                starSystemRepository.SaveEDDIStarSystem(CurrentStarSystemData);
            }

            edsmFetchLogsButton.Content = "Log obtained";
        }
 public void TestSqlRepositoryMissing()
 {
     IEDDIStarSystemRepository starSystemRepository = new EDDIStarSystemSqLiteRepository();
     EDDIStarSystem DBData = starSystemRepository.GetEDDIStarSystem("Not here");
     Assert.IsNull(DBData);
 }