public async Task Should_not_throw_exception_when_directory_not_present()
        {
            var resourceDirectory = new FilesystemDirectory(ResourceHelpers.GetResourceDirectoryInfo());

            var sut = resourceDirectory.GetDirectory($"does_not_exist_{Guid.NewGuid()}");
            await sut.DeleteAsync();
        }
        public async Task Should_delete_a_directory()
        {
            var resourceDirectory = new FilesystemDirectory(ResourceHelpers.GetResourceDirectoryInfo());

            var sut = resourceDirectory.GetDirectory($"testfolder_{Guid.NewGuid()}");
            await sut.CreateDirectoryAsync();

            sut.Exists.Should().BeTrue();
            await sut.DeleteAsync();

            sut.Exists.Should().BeFalse();
        }
Exemple #3
0
        public async Task Should_not_blow_up_if_folder_already_exists()
        {
            var resourceDirectory = new FilesystemDirectory(ResourceHelpers.GetResourceDirectoryInfo());

            var sut = resourceDirectory.GetDirectory($"testfolder_{Guid.NewGuid()}");

            await sut.CreateDirectoryAsync();

            sut.Exists.Should().BeTrue();
            await sut.CreateDirectoryAsync();

            await sut.DeleteAsync();
        }
        public async Task Should_give_handle_to_nonexistent_file()
        {
            const string tempFileName = "test.txt";

            var resourceDirectory = new FilesystemDirectory(ResourceHelpers.GetResourceDirectoryInfo());
            var directory         = resourceDirectory.GetDirectory($"testfolder_{Guid.NewGuid()}");

            var tempFile = directory.GetFile(tempFileName);

            tempFile.Exists.Should().BeFalse();
            tempFile.RealPath.Should().Be(Path.Combine(directory.RealPath, tempFileName));

            await directory.DeleteAsync();
        }
        public async Task Should_be_able_to_write_to_file()
        {
            const string tempFileName = "test.txt";

            var resourceDirectory = new FilesystemDirectory(ResourceHelpers.GetResourceDirectoryInfo());
            var directory         = resourceDirectory.GetDirectory($"level1/testfolder_{Guid.NewGuid()}");

            var tempFile = directory.GetFile(tempFileName);

            using (var stream = await tempFile.OpenWriteAsync())
                using (var writer = new StreamWriter(stream))
                {
                    writer.Write(WRITE_CONTENT);
                }

            File.Exists(tempFile.RealPath).Should().BeTrue();
            File.Delete(tempFile.RealPath);

            await directory.DeleteAsync();
        }