annotate WarFoundryFactoryFactoryTest.cs @ 5:90f63edddc94

Re #30 - Migrate WarFoundry to .csproj * Migrate API tests to .csproj and remove .mdp Also remove old test results from source control
author IBBoard <dev@ibboard.co.uk>
date Tue, 17 Feb 2009 16:30:12 +0000
parents 4222cfa99c78
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
4222cfa99c78 Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
1 // This file (WarFoundryFactoryFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard.
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
4
4222cfa99c78 Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using NUnit.Framework;
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using IBBoard;
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.WarFoundry.API.Objects;
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.WarFoundry.API.Factories.Xml;
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 namespace IBBoard.WarFoundry.API.Factories
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 [TestFixture()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 public class AbstractNativeWarFoundryFactoryTest
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 public void TestFactoryReturnsCorrectClassForDefault()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 WarFoundryFactoryFactory.GetFactoryFactory().DefaultType = GetDefaultFactoryClass();
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 Assert.AreEqual(GetDefaultFactoryClass(), WarFoundryFactoryFactory.GetFactoryFactory().GetFactory().GetType(), "AbstractNativeWarFoundryFactory returned incorrect default factory type");
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 [Ignore("Only one class of factory exists in current implementation")]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 public void TestFactoryReturnsCorrectClassForAlteredDefault()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 WarFoundryFactoryFactory.GetFactoryFactory().DefaultType = GetDefaultFactoryClass();
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 WarFoundryFactoryFactory.GetFactoryFactory().DefaultType = GetOtherFactoryClass();
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 Assert.AreEqual(GetOtherFactoryClass(), WarFoundryFactoryFactory.GetFactoryFactory().GetFactory().GetType(), "AbstractNativeWarFoundryFactory returned incorrect default factory type for updated factory");
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 public void TestFactoryReturnsCorrectClassForXmlFactory()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 Assert.AreEqual(WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass()).GetType(), GetFactoryClass(), "AbstractNativeWarFoundryFactory failed to return correct type when passed a valid type");
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 public void TestFactoryReturnsEqualFactoryForMatchingClasses()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 IWarFoundryFactory first = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass());
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 IWarFoundryFactory second = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass());
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 Assert.AreEqual(first, second, "AbstractNativeWarFoundryFactory failed to return equal factory for matching string");
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 public void TestFactoryReturnsSameFactoryForMatchingClasses()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 IWarFoundryFactory first = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass());
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 IWarFoundryFactory second = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass());
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 Assert.IsTrue(first == second, "AbstractNativeWarFoundryFactory failed to return cached factory");
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 //[ExpectedException(typeof(ArgumentException), ExpectedMessage="was not a subtype", MatchType=MessageMatch.Contains )]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 [ExpectedException(typeof(ArgumentException))]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 public void TestFactoryThrowsArgumentExceptionForInvalidClass()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetInvalidFactoryClass());
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 Assert.Fail("Exceptect exception was not thrown");
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 //[ExpectedException(typeof(ArgumentException), ExpectedMessage="was not a subtype", MatchType=MessageMatch.Contains )]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 [ExpectedException(typeof(ArgumentException))]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 public void TestFactoryThrowsArgumentExceptionForAbstractClass()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(typeof(AbstractNativeWarFoundryFactory));
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 Assert.Fail("Exceptect exception was not thrown");
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 [Ignore("Only one class of factory exists in current implementation")]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74 public void TestFactoryReturnsEqualFactoriesForSameClassAfterDifferentClasses()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76 IWarFoundryFactory first = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass());
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77 WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetOtherFactoryClass());
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
78 IWarFoundryFactory second = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass());
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 Assert.AreEqual(first, second, "AbstractNativeWarFoundryFactory did not return the same factory after creating a new factory of a different class");
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
81
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
82 private Type GetDefaultFactoryClass()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84 return typeof(WarFoundryXmlFactory);
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
86
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 private Type GetInvalidFactoryClass()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 return typeof(String);
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 private Type GetFactoryClass()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 return typeof(WarFoundryXmlFactory);
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97 private Type GetOtherFactoryClass()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 //TODO: Fill in when we have a second class
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 return null;
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 }