예제 #1
0
        public void DirExists_should_return_expected_results()
        {
            var fileResolver = new FileResolver();
            var tempDir      = Path.Combine(Path.GetTempPath(), $"BICEP_TESTDIR_{Guid.NewGuid()}");
            var tempFile     = Path.Combine(tempDir, $"BICEP_TEST_{Guid.NewGuid()}");
            var tempChildDir = Path.Combine(tempDir, $"BICEP_TESTCHILDDIR_{Guid.NewGuid()}");

            // make parent dir
            Directory.CreateDirectory(tempDir);
            fileResolver.TryDirExists(PathHelper.FilePathToFileUrl(tempDir)).Should().BeTrue();
            fileResolver.TryDirExists(PathHelper.FilePathToFileUrl(tempFile)).Should().BeFalse();
            // add a file to parent dir
            File.WriteAllText(tempFile, "abcd\r\ndef");
            fileResolver.TryDirExists(PathHelper.FilePathToFileUrl(tempDir)).Should().BeTrue();
            fileResolver.TryDirExists(PathHelper.FilePathToFileUrl(tempFile)).Should().BeFalse();
            // make child dir
            Directory.CreateDirectory(tempChildDir);
            fileResolver.TryDirExists(PathHelper.FilePathToFileUrl(tempChildDir)).Should().BeTrue();
        }