Example #1
0
        public void FileModifierTest()
        {
            // Test that the filename is "~NA~" if a bad path is passed.
            FileModifier fmbad = new FileModifier("bogusfile.ini");

            Assert.AreEqual("~NA~", fmbad.Filename);

            string       path = Environment.CurrentDirectory + "/MyECFMail.ini";
            FileModifier fm   = new FileModifier(path);

            Assert.IsNotNull(fm);

            // Check that the path was set correctly
            Assert.AreEqual(path, fm.Filename);

            // Test that bool property IsCreated is true after successfully creation.
            Assert.IsTrue(fm.IsCreated);

            // Assert that you can just reset the path.  It must be set in the ctor privately.
            fm.Filename = "bogus.ini";
            Assert.AreNotEqual("bogus.ini", fm.Filename);
            // Filename should still be as it was in ctor.
            Assert.AreEqual(path, fm.Filename);

            // Get the LastAccessTime and LastAccessTimeUtc from the private FileIOManager object.
            DateTime lat = fm.GetLastWriteTime();

            Assert.IsNotNull(lat);

            DateTime latUtc = fm.GetLastWriteTimeUtc();

            Assert.IsNotNull(latUtc);

            //Debug.WriteLine("lat: " + lat + "\nlatUtc: " + latUtc.ToLocalTime());
        }