public void TestLoadNoFile() { // Arrange Appointments testApps = new Appointments(); PrivateObject privApp = new PrivateObject(testApps); privApp.SetField("fileName", String.Empty); // Act bool successfullLoad = testApps.Load(); // Assert Assert.IsFalse(successfullLoad, "The appointment didn't load from a file!"); }
public void TestLoadInvalidFile() { // Arrange Appointments testApps = new Appointments(); PrivateObject privApps = new PrivateObject(testApps); privApps.SetField("fileName", "UnitTests/LoadInvalid.xml"); // Act bool successfullLoad = testApps.Load(); // Assert Assert.IsFalse(successfullLoad, "The appointment loaded an invalid file."); }
public void TestLoadValid() { // Arrange Appointments testApps = new Appointments(); PrivateObject privApps = new PrivateObject(testApps); privApps.SetField("fileName", "UnitTests/Load.xml"); DateTime dt = new DateTime(DateTime.Now.Year + 1, 1, 1, 0, 0, 0); // Act bool successfullLoad = testApps.Load(); // Assert Assert.IsTrue(successfullLoad, "The file wasn't loaded!"); for (int i = 0; i < testApps.Count; ++i) { Assert.AreEqual("Description: Test Appointment " + i + "\nLocation: Test Location", testApps[i].DisplayableDescription, "The appointments description doesn't match!"); Assert.AreEqual(30, testApps[i].Length, "The appointments length is not the same!"); Assert.AreEqual(dt, testApps[i].Start, "The appointments starting time is not the same!"); } }