PageRenderTime 88ms CodeModel.GetById 83ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Otis.Tests/FunctionMapTest.cs

http://otis-lib.googlecode.com/
C# | 67 lines | 45 code | 8 blank | 14 comment | 0 complexity | ea6ee6fcb0d3ad34576728f65f5dbf50 MD5 | raw file
 1/*
 2 * Created by: Zdeslav Vojkovic
 3 * Created: Wednesday, October 24, 2007
 4 */
 5
 6using System;
 7using System.CodeDom;
 8using System.Collections.Generic;
 9using NUnit.Framework;
10using Otis.CodeGen;
11
12namespace Otis.Tests
13{
14	[TestFixture]
15	public class FunctionMapTest
16	{
17		[SetUp]
18		public void SetUp() {}
19
20		[TearDown]
21		public void TearDown() {}
22
23		[Test]
24		[ExpectedException(typeof(OtisException))]
25		public void Registration_Fails_If_Type_Doesnt_Implement_IAggregateFunction()
26		{
27			FunctionMap map = new FunctionMap();
28			map.Register("test", typeof(string));
29		}
30
31		[Test]
32		public void Registration_Suceeds_For_Well_Implemented_Aggregate_Function()
33		{
34			FunctionMap map = new FunctionMap();
35			map.Register("test", typeof(TestFn<int>));
36			Type t1 = typeof(TestFn<int>);
37			Type t2 = map.GetTypeForFunction("test");
38			Assert.AreEqual(typeof(TestFn<int>), map.GetTypeForFunction("test"));
39		}
40
41		[Test]
42		[ExpectedException(typeof(OtisException))]
43		public void Retrieving_Unregistered_Function_Fails()
44		{
45			FunctionMap map = new FunctionMap();
46			map.GetTypeForFunction("test");
47		}
48	}
49	/*
50	class TestFn<T> : IAggregateFunction<T> 
51	{
52		public void Initialize(T initialValue){}
53		public void ProcessValue(T value){}
54		public int ProcessedItemCount { get { return 0; } }
55		public T Result { get { return default(T); } }
56		public string ExpressionFormat { get { return null; }
57		}
58	}*/
59
60	class TestFn<T> : IAggregateFunctionCodeGenerator 
61	{
62		public IEnumerable<CodeStatement> GetInitializationStatements(AggregateFunctionContext context) { return null; }
63		public IEnumerable<string> GetIterationStatements(AggregateFunctionContext context, IList<AggregateExpressionPathItem> pathItems) { return null; }
64		public CodeStatement GetAssignmentStatement(AggregateFunctionContext context) { return null; }
65	}
66}
67