Mercurial > repos > IBBoard.WarFoundry.API.Tests
changeset 10:ad8f0bf1f894
Re #124: Remove factory factory
* Remove factory factory test
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 15 Aug 2009 09:38:54 +0000 |
parents | f96169484ba5 |
children | 8d9d49332d44 |
files | IBBoard.WarFoundry.API.Tests.csproj WarFoundryFactoryFactoryTest.cs |
diffstat | 2 files changed, 0 insertions(+), 104 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ <Compile Include="MockObjects\MockSystemFactory.cs" /> <Compile Include="MockObjects\MockRaceZipFile.cs" /> <Compile Include="MockObjects\MockSystemZipFile.cs" /> - <Compile Include="WarFoundryFactoryFactoryTest.cs" /> <Compile Include="WarFoundryFactoryTest.cs" /> <Compile Include="WarFoundryLoaderTest.cs" /> </ItemGroup>
--- 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; - } - } -}