public async void SimulationModeFileSystem_EnumerateFiles_AddedFiles() { var fileSystem = new SimulationModeFileSystem(); var dirPath = Directory.GetCurrentDirectory(); var expected = Directory.EnumerateFiles(dirPath, "*.*", SearchOption.TopDirectoryOnly); var actual = fileSystem.EnumerateFiles(dirPath, "*.*", SearchOption.TopDirectoryOnly); Assert.Equal(expected, actual); var contents = "DummyContents"; byte[] bytes = Encoding.UTF8.GetBytes(contents); await fileSystem.AddFileAsync(Path.Combine(dirPath, "DummyOutputPath.txt"), new MemoryStream(bytes)); actual = fileSystem.EnumerateFiles(dirPath, "*.*", SearchOption.TopDirectoryOnly); Assert.Contains(actual, f => f.Equals(Path.Combine(dirPath, "DummyOutputPath.txt"))); actual = fileSystem.EnumerateFiles(dirPath, "DummyOutputPat?.txt", SearchOption.TopDirectoryOnly); Assert.Contains(actual, f => f.Equals(Path.Combine(dirPath, "DummyOutputPath.txt"))); actual = fileSystem.EnumerateFiles(dirPath, "*OutputPath.t?t", SearchOption.TopDirectoryOnly); Assert.Contains(actual, f => f.Equals(Path.Combine(dirPath, "DummyOutputPath.txt"))); fileSystem.CreateDirectory(Path.Combine(dirPath, "test_dir")); await fileSystem.AddFileAsync(Path.Combine(dirPath, "test_dir", "TestFile.abc"), new MemoryStream(bytes)); actual = fileSystem.EnumerateFiles(dirPath, "*.*", SearchOption.AllDirectories); Assert.Contains(actual, f => f.Equals(Path.Combine(dirPath, "DummyOutputPath.txt"))); Assert.Contains(actual, f => f.Equals(Path.Combine(dirPath, "test_dir", "TestFile.abc"))); actual = fileSystem.EnumerateFiles(dirPath, "*.abc", SearchOption.AllDirectories); Assert.DoesNotContain(actual, f => f.Equals(Path.Combine(dirPath, "DummyOutputPath.txt"))); Assert.Contains(actual, f => f.Equals(Path.Combine(dirPath, "test_dir", "TestFile.abc"))); }
public void SimulationModeFileSystem_EnumerateFiles_RemovedFiles() { var fileSystem = new SimulationModeFileSystem(); var dirPath = Path.GetTempPath(); dirPath = Directory.CreateDirectory(Guid.NewGuid().ToString()).FullName; var contents = "DummyContents"; byte[] bytes = Encoding.UTF8.GetBytes(contents); File.WriteAllBytes(Path.Combine(dirPath, "test_file.txt"), bytes); var expected = Directory.EnumerateFiles(dirPath, "*.*", SearchOption.TopDirectoryOnly); var actual = fileSystem.EnumerateFiles(dirPath, "*.*", SearchOption.TopDirectoryOnly); Assert.Equal(expected, actual); Assert.Contains(actual, f => f.Equals(Path.Combine(dirPath, "test_file.txt"))); File.Delete(Path.Combine(dirPath, "test_file.txt")); actual = fileSystem.EnumerateFiles(dirPath, "*.*", SearchOption.TopDirectoryOnly); Assert.DoesNotContain(actual, f => f.Equals(Path.Combine(dirPath, "test_file.txt"))); }