2008 Advent Calendar December 9th
1: public class Advent9 : IDisposable
2: {
3: private IFileUtil m_file;
4:
5: private void SetUp(string content)
6: {
7: m_file = new FileUtil("SomeFile.txt");
8: m_file.Create(content);
9: }
10:
11: public void Dispose()
12: {
13: m_file.Delete();
14: }
15:
16: [Fact]
17: public void TestReadOK()
18: {
19: SetUp("CONTENT");
20: Assert.DoesNotThrow(() => { m_file.Read(); });
21: }
22:
23: [Fact]
24: public void TestReadFails()
25: {
26: SetUp("SHOULD NOT BE ABLE TO READ THIS");
27: m_file.Readable = false;
28: Assert.Throws<AccessViolationException>(() => { m_file.Read(); });
29: }
30: }
So now that I got a setup-method that that accepts desired content I should probably use it to actually verify the content of the file that reads OK...