view API/Savers/Xml/WarFoundryXmlFileSaverTests.cs @ 98:49c5e24decb9

Re #338: WarFoundry.API - Save System Data * Make sure MockGameSystem doesn't cause null pointers during tests (separate bug to fix properly) * Add test for saving GameSystem * Add implementation of test to XML version
author IBBoard <dev@ibboard.co.uk>
date Wed, 09 Mar 2011 20:45:13 +0000
parents 45b80fed5e2a
children dd384f35a96f
line wrap: on
line source

using System;
using NUnit.Framework;
using System.IO;
using IBBoard.WarFoundry.API.Objects;
using IBBoard.Lang;

namespace IBBoard.WarFoundry.API.Savers.Xml
{
	[TestFixture()]
	public class WarFoundryXmlFileSaverTests : IWarFoundryFileSaverTests
	{
		protected override IWarFoundryFileSaver GetSaver()
		{
			return new WarFoundryXmlFileSaver();
		}

		protected override string GetEntryName(WarFoundryLoadedObject obj)
		{
			return obj.ID + GetFileExtensionForType(obj);
		}

		protected override string GetFileExtensionForType(WarFoundryLoadedObject obj)
		{
			return GetSaver().GetFileExtension(obj);
		}

		protected override string GetArmyExtension()
		{
			return ".armyx";
		}

		protected override string GetRaceExtension()
		{
			return ".racex";
		}

		protected override string GetGameSystemExtension()
		{
			return ".systemx";
		}

		public override byte[] GetGameSystemContentBytes()
		{
			return StringManipulation.StringToBytes(@"<?xml version=""1.0"" encoding=""UTF-8""?><system xmlns=""http://ibboard.co.uk/warfoundry/system"" xmlns:cats=""http://ibboard.co.uk/warfoundry/cats"" id=""mocksystem"" name=""Mock Game System"" defaultArmySize=""0"" warn=""false"" allowAllies=""false""><categories /><sysStatsList defaultStats=""default""><sysStats id=""default"" /></sysStatsList></system>");
		}
	}
}