private async Task Open() { try { WinForms.OpenFileDialog dialog = new WinForms.OpenFileDialog(); dialog.Filter = "Files | *.scl;"; if (dialog.ShowDialog() == WinForms.DialogResult.OK) { PopulateTableFromString(LoadSaveFromToTextFile.ReadFile(dialog.FileName)); } } catch (Exception ex) { throw new Exception("Selected file invalid"); } }
public void TestReadAndPopulateFromFile() { var l = new LegendViewModel(30, 0); var Expectlist = l.ListOfLagendItems.ToList(); var str = l.ToString(); var path = @"F:\scale.scl"; LoadSaveFromToTextFile.SaveFile(str, path); var Getslist = l.PopulateTableFromString(LoadSaveFromToTextFile.ReadFile(path)); TempFileManager.DeleteTmpFile(path); Getslist.ForEach(x => { Assert.AreEqual(Expectlist[Getslist.IndexOf(x)], x); }); }