public void IsDirectoryTest_NonExistantDirectory_ThrowsException() { // Given string directoryPath = DexterCSTestUtil.TestingDirectory + @"\" + DexterCSTestUtil.RandomString(); FileInfo fileInfo = new FileInfo(directoryPath); // When bool result = DexterUtil.IsDirectory(fileInfo); // Then // FileNotFoundException is thrown }
public void IsDirectoryTest_ExistingFile_ReturnsFalse() { try { // Given string filePath = DexterCSTestUtil.TestingDirectory + @"\" + DexterCSTestUtil.RandomString(); File.Create(filePath).Close(); FileInfo fileInfo = new FileInfo(filePath); // When bool result = DexterUtil.IsDirectory(fileInfo); // Then Assert.IsFalse(result); } finally { DexterCSTestUtil.ClearTestingDirectory(); } }
public void IsDirectoryTest_ExistingDirectory_ReturnsTrue() { try { // Given string directoryPath = DexterCSTestUtil.TestingDirectory + @"\" + DexterCSTestUtil.RandomString(); Directory.CreateDirectory(directoryPath); FileInfo fileInfo = new FileInfo(directoryPath); // When bool result = DexterUtil.IsDirectory(fileInfo); // Then Assert.IsTrue(result); } finally { DexterCSTestUtil.ClearTestingDirectory(); } }
public void GetSourcecodeFromFileTest_ComplexAndBigFileContent_ReturnsFileContent() { try { // Given string filePath = DexterCSTestUtil.TestingDirectory + @"\" + DexterCSTestUtil.RandomString(); string fileContent = DexterCSTestUtil.RandomString(10000); StreamWriter streamWriter = File.CreateText(filePath); streamWriter.Write(fileContent); streamWriter.Close(); FileInfo fileInfo = new FileInfo(filePath); // When string result = DexterUtil.GetSourcecodeFromFile(filePath); // Then Assert.AreEqual(fileContent, result); } finally { DexterCSTestUtil.ClearTestingDirectory(); } }