~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
namespace TomboyTest
{
	using System;
	using System.IO;
	using NUnit.Framework;
	using Tomboy;

	class DebugLogger : ILogger
	{
		public string Message = null;
		public object[] Arguments = null;

		public void Log (string msg, params object[] args)
		{
			Message = msg;
			Arguments = args;
		}
	}

	[TestFixture]
	public class LoggerTest
	{
		DebugLogger logger = null;

		[SetUp]
		public void Setup ()
		{
			logger = new DebugLogger ();
			Logger.Instance = logger;
		}

		[Test]
		public void LogSimple ()
		{
			Logger.Log ("Foo");
			Assert.AreEqual ("Foo", logger.Message);
			Assert.AreEqual (0, logger.Arguments.Length);
		}

		[Test]
		public void LogOneArgument ()
		{
			Logger.Log ("Foo", "arg");
			Assert.AreEqual ("Foo", logger.Message);
			Assert.AreEqual (1, logger.Arguments.Length);
			Assert.AreEqual ("arg", logger.Arguments[0]);
		}

		[Test]
		public void LogTwoArguments ()
		{
			Logger.Log ("Foo", 1, 2);
			Assert.AreEqual ("Foo", logger.Message);
			Assert.AreEqual (2, logger.Arguments.Length);
			Assert.AreEqual (1, logger.Arguments[0]);
			Assert.AreEqual (2, logger.Arguments[1]);
		}
	}
}