Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Host file contention will no longer cause contents to be deleted. Fixes
- Loading branch information
1 parent
f7159c0
commit a8c8a51
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Machine.Specifications; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace RichardSzalay.Hosts.Tests | ||
{ | ||
public class FileInfoResourceSpec | ||
{ | ||
[Subject(typeof(FileInfoResource), "OpenWrite")] | ||
public class When_writing_to_the_resource | ||
{ | ||
Establish context = () => | ||
{ | ||
tempFile = new FileInfo(Path.GetTempFileName()); | ||
File.WriteAllText(tempFile.FullName, "Test original longer text"); | ||
sut = new FileInfoResource(tempFile); | ||
}; | ||
|
||
Because of = () => | ||
{ | ||
using (Stream stream = sut.OpenWrite()) | ||
using (StreamWriter writer = new StreamWriter(stream)) | ||
{ | ||
writer.Write("Test 2"); | ||
stream.Flush(); | ||
} | ||
result = File.ReadAllText(tempFile.FullName); | ||
}; | ||
|
||
It should_overwrite_existing_contents = () => | ||
result.ShouldEqual("Test 2"); | ||
|
||
static FileInfoResource sut; | ||
static FileInfo tempFile; | ||
static string result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters