///<summary> ///Test for the archive start condition ///If the logdirectory the method should stop archiving and return a false ///</summary> public void LogDirectoryNotPass() { //Arrange bool expected = false; //For testing, make sure directory exists then delete it if (Directory.Exists(logStorage)) { DirClean(); try { Directory.Delete(logStorage, true); } catch (IOException) { Thread.Sleep(0); Directory.Delete(logStorage, true); } //Directory.Delete(logStorage); } //Act bool actual = manager.RunArchive(); Directory.CreateDirectory(logStorage); Console.WriteLine(manager.GetMessage()); //Assert Assert.AreEqual(expected, actual); }
public void RunArchivePass() { //Arrange //Make sure logStorage exists LogStorageCheck(); ArchiveManager archiver = new ArchiveManager(); bool expected = true; for (int i = 1; i < 10; i++) { string fileName = DateTime.Now.AddDays(-1 * (logLife + i)).ToString(dateFormat) + logExtension; File.WriteAllText(logStorage + fileName, "testing"); } DirClean(); //Act bool actual = archiver.RunArchive(); Console.WriteLine(archiver.GetMessage()); //Assert Assert.AreEqual(expected, actual); }