private void InitExistingDatabase() { var existing = DatabaseApi.GetAllCompetitions(); if (existing != null && existing.Any()) { DataBaseNames = new ObservableCollection <string>(existing); SelectedDatabase = DataBaseNames.First(); } }
private void InitExistingDatabase() { var existing = DatabaseApi.GetAllCompetitions(); if (existing != null && existing.Any()) { var dataBaseViewModels = new List <DataBaseViewModel>(); foreach (var dbPath in existing) { dataBaseViewModels.Add(new DataBaseViewModel { DatabasePath = dbPath }); } SelectedDatabase = dataBaseViewModels.First(); DataBaseNames = new ObservableCollection <DataBaseViewModel>(dataBaseViewModels); } }
public void CreateNewCompetition_NewDbCreated() { Directory.Delete(@"C:\FeltAdmin\TEST\Database"); var expectedPath = Path.Combine(@"C:\FeltAdmin\TEST\Database", "TestStevne_2016.02.26"); var expectedPath1 = Path.Combine(@"C:\FeltAdmin\TEST\Database", "TestStevne_2016.02.26-1"); var expectedPath2 = Path.Combine(@"C:\FeltAdmin\TEST\Database", "TestStevne_2016.02.26-2"); DatabaseApi.CreateNewCompetition("FeltAdmin", "TestStevne", new DateTime(2016, 2, 26)); Thread.Sleep(100); DatabaseApi.CreateNewCompetition("FeltAdmin", "TestStevne", new DateTime(2016, 2, 26)); Thread.Sleep(100); DatabaseApi.CreateNewCompetition("FeltAdmin", "TestStevne", new DateTime(2016, 2, 26)); var directories = DatabaseApi.GetAllCompetitions(); Assert.IsTrue(Directory.Exists(expectedPath)); Assert.IsTrue(Directory.Exists(expectedPath1)); Assert.IsTrue(Directory.Exists(expectedPath2)); Assert.AreEqual(expectedPath2, directories[0]); Assert.AreEqual(expectedPath1, directories[1]); Assert.AreEqual(expectedPath, directories[2]); }