public void InstanciationVerifyCreationDirectory () { var path = AppDomain.CurrentDomain.BaseDirectory; if (Directory.GetDirectories (path).Count (p => Path.GetFileName (p) == DateTime.Now.ToString ("yyyy-MM-dd")) == 1) Directory.Delete (Path.Combine (path, DateTime.Now.ToString ("yyyy-MM-dd")), true); using (var logStorage = new XmlWriterTraceListener("Application 1", AppDomain.CurrentDomain.BaseDirectory)) { logStorage.WriteLineEx ("Test", "1"); logStorage.Flush (); var nbDirectoryWithCurrentDay = Directory.GetDirectories (logStorage.BaseRootPath).Count (p => Path.GetFileName (p) == DateTime.Now.ToString ("yyyy-MM-dd")); Assert.IsTrue (nbDirectoryWithCurrentDay == 1, "Nb Directory With Current Day Name : " + nbDirectoryWithCurrentDay); } }
public void Instanciation5FileCreateFor5Instanciation () { var path = AppDomain.CurrentDomain.BaseDirectory; var pathDirectoryDaily = Path.Combine (path, DateTime.Now.ToString ("yyyy-MM-dd")); if (Directory.GetDirectories (path).Count (p => Path.GetFileName (p) == DateTime.Now.ToString ("yyyy-MM-dd")) == 1) Directory.Delete (pathDirectoryDaily, true); for (int i=1; i<=5; i++) { var pathFileSession = Path.Combine (pathDirectoryDaily, "Working_session_" + i + ".xml"); using (var logStorage = new XmlWriterTraceListener("Application 1", AppDomain.CurrentDomain.BaseDirectory)) { logStorage.WriteLineEx ("Test", "1"); } Assert.IsTrue (File.Exists (pathFileSession)); } }
public void InstanciationExceptionWithCustomPathInvalid () { using (var logStorage = new XmlWriterTraceListener("Application 1", @"B:\")) { logStorage.WriteLineEx ("Test", "1"); } }