public void ValidLoadShouldLoadFile() { TestStorage loadSensor = new TestStorage(); TaskListFile file = new TaskListFile(loadSensor); file.Load("TestLoadFile"); Assert.AreEqual("TestLoadFile", loadSensor.LoadedFile, string.Format("Loaded file name should be TestLoadFile, not {0}", loadSensor.LoadedFile)); }
public void InvalidLoadShouldCreateEmptyListAndNotifyUser() { using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); TaskListFile file = new TaskListFile(new TestStorage()); file.Load("Exception"); string expected = string.Format("There was a problem loading the file.{0}", Environment.NewLine); Assert.AreEqual <string>(expected, sw.ToString(), string.Format("Expected output is {0}, not {1}", expected, sw.ToString())); } }
public void NonExistentFileLoadShouldCreateEmptyListAndNotifyUser() { using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); TaskListFile file = new TaskListFile(new TestStorage()); file.Load("Nonexistent"); string expected = string.Format("Saved file doesn't exist at Nonexistent.{0}", Environment.NewLine); Assert.AreEqual <string>(expected, sw.ToString(), string.Format("Expected output is {0}, not {1}", expected, sw.ToString())); } }
public void SaveAfterLoadShouldDefaultToFileThatWasLoaded() { TestStorage saveSensor = new TestStorage(); TaskListFile file = new TaskListFile(saveSensor); file.Load("LoadTestFile"); file.Save(new TaskList(), new TestInputParser(new List <string> { })); //null saveSensor.Clear(); file.Save(new TaskList(), new TestInputParser(new List <string> { })); //string.Empty Assert.AreEqual("LoadTestFile", saveSensor.SavedFile, string.Format("Saved file name should be LoadTestFile, not {0}", saveSensor.SavedFile)); }