# HG changeset patch # User IBBoard # Date 1250329134 0 # Node ID ad8f0bf1f894d3ae1574307dfad0ba918278dbf5 # Parent f96169484ba52efd8202df2204825aebfef96609 Re #124: Remove factory factory * Remove factory factory test diff -r f96169484ba5 -r ad8f0bf1f894 IBBoard.WarFoundry.API.Tests.csproj --- a/IBBoard.WarFoundry.API.Tests.csproj Sun Mar 15 15:21:58 2009 +0000 +++ b/IBBoard.WarFoundry.API.Tests.csproj Sat Aug 15 09:38:54 2009 +0000 @@ -43,7 +43,6 @@ - diff -r f96169484ba5 -r ad8f0bf1f894 WarFoundryFactoryFactoryTest.cs --- a/WarFoundryFactoryFactoryTest.cs Sun Mar 15 15:21:58 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -// This file (WarFoundryFactoryFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard. -// -// 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. - -using System; -using NUnit.Framework; -using IBBoard; -using IBBoard.WarFoundry.API.Objects; -using IBBoard.WarFoundry.API.Factories.Xml; - -namespace IBBoard.WarFoundry.API.Factories -{ - [TestFixture()] - public class AbstractNativeWarFoundryFactoryTest - { - [Test()] - public void TestFactoryReturnsCorrectClassForDefault() - { - WarFoundryFactoryFactory.GetFactoryFactory().DefaultType = GetDefaultFactoryClass(); - Assert.AreEqual(GetDefaultFactoryClass(), WarFoundryFactoryFactory.GetFactoryFactory().GetFactory().GetType(), "AbstractNativeWarFoundryFactory returned incorrect default factory type"); - } - - [Test()] - [Ignore("Only one class of factory exists in current implementation")] - public void TestFactoryReturnsCorrectClassForAlteredDefault() - { - WarFoundryFactoryFactory.GetFactoryFactory().DefaultType = GetDefaultFactoryClass(); - WarFoundryFactoryFactory.GetFactoryFactory().DefaultType = GetOtherFactoryClass(); - Assert.AreEqual(GetOtherFactoryClass(), WarFoundryFactoryFactory.GetFactoryFactory().GetFactory().GetType(), "AbstractNativeWarFoundryFactory returned incorrect default factory type for updated factory"); - } - - [Test()] - public void TestFactoryReturnsCorrectClassForXmlFactory() - { - Assert.AreEqual(WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass()).GetType(), GetFactoryClass(), "AbstractNativeWarFoundryFactory failed to return correct type when passed a valid type"); - } - - [Test()] - public void TestFactoryReturnsEqualFactoryForMatchingClasses() - { - IWarFoundryFactory first = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass()); - IWarFoundryFactory second = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass()); - Assert.AreEqual(first, second, "AbstractNativeWarFoundryFactory failed to return equal factory for matching string"); - } - - [Test()] - public void TestFactoryReturnsSameFactoryForMatchingClasses() - { - IWarFoundryFactory first = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass()); - IWarFoundryFactory second = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass()); - Assert.IsTrue(first == second, "AbstractNativeWarFoundryFactory failed to return cached factory"); - } - - [Test()] - //[ExpectedException(typeof(ArgumentException), ExpectedMessage="was not a subtype", MatchType=MessageMatch.Contains )] - [ExpectedException(typeof(ArgumentException))] - public void TestFactoryThrowsArgumentExceptionForInvalidClass() - { - WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetInvalidFactoryClass()); - Assert.Fail("Exceptect exception was not thrown"); - } - - [Test()] - //[ExpectedException(typeof(ArgumentException), ExpectedMessage="was not a subtype", MatchType=MessageMatch.Contains )] - [ExpectedException(typeof(ArgumentException))] - public void TestFactoryThrowsArgumentExceptionForAbstractClass() - { - WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(typeof(AbstractNativeWarFoundryFactory)); - Assert.Fail("Exceptect exception was not thrown"); - } - - [Test()] - [Ignore("Only one class of factory exists in current implementation")] - public void TestFactoryReturnsEqualFactoriesForSameClassAfterDifferentClasses() - { - IWarFoundryFactory first = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass()); - WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetOtherFactoryClass()); - IWarFoundryFactory second = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(GetFactoryClass()); - Assert.AreEqual(first, second, "AbstractNativeWarFoundryFactory did not return the same factory after creating a new factory of a different class"); - } - - private Type GetDefaultFactoryClass() - { - return typeof(WarFoundryXmlFactory); - } - - private Type GetInvalidFactoryClass() - { - return typeof(String); - } - - private Type GetFactoryClass() - { - return typeof(WarFoundryXmlFactory); - } - - private Type GetOtherFactoryClass() - { - //TODO: Fill in when we have a second class - return null; - } - } -}