Beispiel #1
0
        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
        }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
        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();
            }
        }
Beispiel #4
0
        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();
            }
        }