~ubuntu-branches/ubuntu/lucid/tomboy/lucid-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
namespace TomboyTest
{
	using System;
	using System.IO;
	using NUnit.Framework;
	using Tomboy;

	class MyNoteManager : NoteManager
	{
		public string LastDirCreated = null;
		public bool CreatedStartNote = false;
		public bool LoadedNotes = false;

public MyNoteManager () :
		base ("/tmp/notes-dir")
		{
		}

		protected override bool DirectoryExists (string directory)
		{
			return true;
		}

		protected override DirectoryInfo CreateDirectory (string directory)
		{
			LastDirCreated = directory;
			return null;
		}

		protected override PluginManager CreatePluginManager ()
		{
			return null;
		}

		protected override void CreateStartNote ()
		{
			Assert.IsFalse(CreatedStartNote,
			               "CreateStartNote called twice");
			CreatedStartNote = true;
		}

		protected override void LoadNotes ()
		{
			Assert.IsFalse(LoadedNotes, "LoadNotes called twice");
			LoadedNotes = true;
		}
	}

	class MyNoteManagerFirstRun : MyNoteManager
	{
		protected override bool DirectoryExists (string directory)
		{
			return !(directory == "/tmp/notes-dir");
		}
	}

	[TestFixture]
	public class NoteManagerTest
	{
		[Test]
		public void Construct()
		{
			MyNoteManager manager = new MyNoteManager ();
			Assert.IsNull (manager.LastDirCreated);
			Assert.IsTrue (manager.LoadedNotes);
		}

		[Test]
		public void ConstructFirstRun()
		{
			MyNoteManager manager = new MyNoteManagerFirstRun ();
			Assert.AreEqual ("/tmp/notes-dir",
			                 manager.LastDirCreated);
			Assert.IsTrue (manager.CreatedStartNote);
		}
	}
}