Beispiel #1
0
        public void When_File_Was_Deleted_Try_Writing_Log()
        {
            //ARRANGE
            string path = @"C:\Logs\Test\TestFile.txt";

            FileInfo fileInfo = new FileInfo(path);

            if (fileInfo.DirectoryName != null && Directory.Exists(fileInfo.DirectoryName))
            {
                Directory.Delete(fileInfo.DirectoryName, true);
            }

            DLogger logger = new DLogger();

            //ACT
            logger.AddTargetFile(path);
            logger.AddTargetFile(fileInfo);

            File.Delete(path);
            logger.Write("Test");

            //ASSERT
            Assert.IsTrue(File.ReadAllText(path).Contains("Test"));
            File.Delete(path);
        }