Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
view API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs @ 68:a82f164e26e3
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
* Add test for invalid default stats ID
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 04 Jul 2010 19:11:08 +0000 |
parents | d3191c44f163 |
children | 90a9f13b9627 |
line wrap: on
line source
// This file (WarFoundryXmlSystemFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2010 IBBoard // // // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. using System; using NUnit.Framework; using System.IO; using IBBoard.WarFoundry.API.Objects; using NUnit.Framework.SyntaxHelpers; using IBBoard.IO; using System.Xml.Schema; namespace IBBoard.WarFoundry.API.Factories.Xml { [TestFixture()] public class WarFoundryXmlSystemFactoryTest { [Test()] public void TestGettingDefaultStatsIDFullyLoadsGameSystem() { GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx")); Assert.That(system.IsFullyLoaded, Is.False); string temp = system.StandardSystemStatsID; Assert.That(system.IsFullyLoaded, Is.True); } [Test()] public void TestValidDefaultStatsIDLoadsCorrectly() { GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx")); Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats")); Assert.That(system.SystemStats, Has.Length(1)); } [Test()] public void TestValidDefaultStatsIDLoadsCorrectlyWithMultipleStatsSets() { GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-multiple-stats-set.systemx")); Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats")); Assert.That(system.SystemStats, Has.Length(2)); } [Test()] public void TestIncorrectDefaultStatsIDErrors() { TestFileValidationFailure("testdata/xml-system-factory/invalid-default-stats.systemx"); } private void TestFileValidationFailure(string filePath) { FileInfo systemFile = new FileInfo(filePath); try { SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), systemFile); Assert.Fail("Excepted exception not thrown"); } catch (InvalidFileException ex) { Console.WriteLine(ex.Message); Exception innerException = ex.InnerException; Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException))); } } } }