public async Task StoreDataTestAsync() { string fileName = "storageTest.txt"; string expected = "StoreDataTest text for testing"; IStorageService storageService = new DiskStorageService(TestDirectory, TestDirectory); await storageService.StoreDataAsync(expected, fileName); string actual = File.ReadAllText(Path.Combine(TestDirectory, fileName)); Assert.Equal(expected, actual); }
public async Task ListFilesTestAsync() { Directory.CreateDirectory(TestDirectory); string[] expectedFiles = new string[] { "file1", "file2", "file3" }; Array.ForEach(expectedFiles, fileName => { File.Create(Path.Combine(TestDirectory, fileName)).Dispose(); }); IStorageService storageService = new DiskStorageService(TestDirectory, TestDirectory); string[] actualFiles = await storageService.ListFilesAsync(); Assert.Equal(expectedFiles, actualFiles); }
public async Task ReadFileTest() { string fileName = "storageTest.txt"; string expected = "ReadFileTest text for testing"; File.WriteAllText(Path.Combine(TestDirectory, fileName), expected); string actual = ""; IStorageService storageService = new DiskStorageService(TestDirectory, TestDirectory); Stream file = await storageService.ReadFileAsync(fileName); using (StreamReader sr = new StreamReader(file)) { actual = sr.ReadToEnd(); } Assert.Equal(expected, actual); }