Ejemplo n.º 1
0
        public void CreateInitialFolderAndFilesTest_ProvidedDexterHomePath_CreatesBinDirectoryInDexterHome()
        {
            try
            {
                // Given
                DexterConfig dexterConfig   = new DexterConfig();
                string       dexterHomePath = DexterCSTestUtil.TestingDirectory + @"\" + "DexterHome";
                dexterConfig.DexterHome = dexterHomePath;

                // When
                dexterConfig.CreateInitialFolderAndFiles();

                foreach (string s in Directory.GetDirectories(dexterHomePath))
                {
                    Console.WriteLine(s);
                }

                // Then
                Assert.IsTrue(Directory.GetDirectories(dexterHomePath)
                              .Any(x => new DirectoryInfo(x).Name == "bin"));
            }
            finally
            {
                DexterCSTestUtil.ClearTestingDirectory();
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 4
0
        public void CreateInitialFolderAndFilesTest_ProvidedDexterHomePath_CreatesNonEmptyDirectory()
        {
            try
            {
                // Given
                DexterConfig dexterConfig   = new DexterConfig();
                string       dexterHomePath = DexterCSTestUtil.TestingDirectory + @"\" + "DexterHome";
                dexterConfig.DexterHome = dexterHomePath;

                // When
                dexterConfig.CreateInitialFolderAndFiles();

                // Then
                Assert.IsTrue(Directory.GetFileSystemEntries(dexterHomePath).Any());
            }
            finally
            {
                DexterCSTestUtil.ClearTestingDirectory();
            }
        }
Ejemplo n.º 5
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();
            }
        }