public async Task CreateOrAppendTextWorksWithExistingFile() { // --- Arrange const string BODY = "FirstSecond"; var wfs = new AzureFileStorage(ROOT); var file = new AbstractFileDescriptor("Container", null, "TestFile.txt"); using (var textFile = await wfs.CreateTextAsync(file)) { textFile.Writer.Write("First"); } // --- Act using (var textFile = await wfs.CreateOrAppendTextAsync(file)) { textFile.Writer.Write("Second"); } // --- Assert using (var savedFile = await wfs.OpenTextAsync(file)) { var text = savedFile.Reader.ReadToEnd(); text.ShouldBe(BODY); } }
public async Task AppendTextWorksWithSpecificCulture() { // --- Arrange const string BODY = "1,25-1,25"; var wfs = new AzureFileStorage(ROOT); var file = new AbstractFileDescriptor("Container", null, "TestFile.txt"); using (var textFile = await wfs.CreateTextAsync(file, new CultureInfo("hu-hu"))) { textFile.Writer.Write(1.25); } // --- Act using (var textFile = await wfs.AppendTextAsync(file, new CultureInfo("hu-hu"))) { textFile.Writer.Write(-1.25); } // --- Assert using (var savedFile = await wfs.OpenTextAsync(file)) { var text = savedFile.Reader.ReadToEnd(); text.ShouldBe(BODY); } }
public async Task DeleteWorksWithExistingFile() { // --- Arrange var wfs = new AzureFileStorage(ROOT); var file = new AbstractFileDescriptor("Container", null, "TestFile.txt"); using (var textFile = await wfs.CreateTextAsync(file)) { textFile.Writer.Write("Awesome"); } // --- Act var deleted = await wfs.DeleteAsync(file); // --- Assert deleted.ShouldBeTrue(); (await wfs.ExistsAsync(file)).ShouldBeFalse(); }
public async Task CreateTextWorksAsExpected() { // --- Arrange const string BODY = "This is a text file"; var wfs = new AzureFileStorage(ROOT); var file = new AbstractFileDescriptor("Container", null, "TestFile.txt"); // --- Act using (var textFile = await wfs.CreateTextAsync(file)) { textFile.Writer.Write(BODY); } // --- Assert using (var savedFile = await wfs.OpenTextAsync(file)) { var text = savedFile.Reader.ReadToEnd(); text.ShouldBe(BODY); } }