mirror of
https://github.com/LazyDuchess/OpenTS2.git
synced 2025-01-22 08:11:47 -05:00
Test contentmanager.
This commit is contained in:
parent
e9170f9041
commit
8ceb48b0ec
12 changed files with 131 additions and 2 deletions
|
@ -16,12 +16,28 @@ namespace OpenTS2.Content
|
|||
}
|
||||
static EPManager s_instance;
|
||||
|
||||
public int InstalledProducts
|
||||
{
|
||||
get
|
||||
{
|
||||
return _installedProducts;
|
||||
}
|
||||
set
|
||||
{
|
||||
_installedProducts = value;
|
||||
}
|
||||
}
|
||||
|
||||
//mask of all products, minus store.
|
||||
readonly int _installedProducts = 0x3EFFF;
|
||||
int _installedProducts = 0x3EFFF;
|
||||
public EPManager()
|
||||
{
|
||||
s_instance = this;
|
||||
}
|
||||
public EPManager(int installedProducts) : this()
|
||||
{
|
||||
InstalledProducts = installedProducts;
|
||||
}
|
||||
public static List<ProductFlags> GetProductsInMask(int productMask)
|
||||
{
|
||||
var finalList = new List<ProductFlags>();
|
||||
|
|
20
Assets/Tests/OpenTS2/Content/ContentManagerTest.cs
Normal file
20
Assets/Tests/OpenTS2/Content/ContentManagerTest.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using NUnit.Framework;
|
||||
using OpenTS2.Common;
|
||||
using OpenTS2.Content;
|
||||
using OpenTS2.Content.DBPF;
|
||||
using OpenTS2.Engine;
|
||||
using OpenTS2.Files;
|
||||
using OpenTS2.Files.Formats.DBPF;
|
||||
|
||||
public class ContentManagerTest
|
||||
{
|
||||
[Test]
|
||||
public void GetAssetByGlobalTGITest()
|
||||
{
|
||||
TestMain.Initialize();
|
||||
var contentManager = ContentManager.Get();
|
||||
contentManager.Provider.AddPackage("TestAssets/TestPackage.package");
|
||||
var stringAsset = contentManager.Provider.GetAsset<StringSetAsset>(new ResourceKey(1, "testpackage", TypeIDs.STR));
|
||||
Assert.IsNotNull(stringAsset);
|
||||
}
|
||||
}
|
11
Assets/Tests/OpenTS2/Content/ContentManagerTest.cs.meta
Normal file
11
Assets/Tests/OpenTS2/Content/ContentManagerTest.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bfd63c2c05bba0344a8889eda9c99c3c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Tests/OpenTS2/Content/DBPF.meta
Normal file
8
Assets/Tests/OpenTS2/Content/DBPF.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c1227e4188138954ca6e937273442c4e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -3,7 +3,7 @@ using OpenTS2.Content.DBPF;
|
|||
using OpenTS2.Client;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ContentTest
|
||||
public class StringSetTest
|
||||
{
|
||||
[Test]
|
||||
public void StringSetLocalizationTest()
|
26
Assets/Tests/TestMain.cs
Normal file
26
Assets/Tests/TestMain.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using OpenTS2.Assemblies;
|
||||
using OpenTS2.Content;
|
||||
using OpenTS2.Files;
|
||||
using OpenTS2.Files.Formats.DBPF;
|
||||
|
||||
/// <summary>
|
||||
/// Main initialization class for OpenTS2 unit testing.
|
||||
/// </summary>
|
||||
public static class TestMain
|
||||
{
|
||||
static bool s_initialized = false;
|
||||
/// <summary>
|
||||
/// Initializes all singletons, systems and the game assembly.
|
||||
/// </summary>
|
||||
public static void Initialize()
|
||||
{
|
||||
if (s_initialized)
|
||||
return;
|
||||
var epManager = new EPManager((int)ProductFlags.BaseGame);
|
||||
var contentManager = new ContentManager();
|
||||
Filesystem.Initialize(new TestPathProvider(), epManager);
|
||||
CodecAttribute.Initialize();
|
||||
AssemblyHelper.InitializeLoadedAssemblies();
|
||||
s_initialized = true;
|
||||
}
|
||||
}
|
11
Assets/Tests/TestMain.cs.meta
Normal file
11
Assets/Tests/TestMain.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f85fdb2b65bb11148b76bb8dfc971d6b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
25
Assets/Tests/TestPathProvider.cs
Normal file
25
Assets/Tests/TestPathProvider.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using OpenTS2.Content;
|
||||
using OpenTS2.Content.Interfaces;
|
||||
|
||||
public class TestPathProvider : IPathProvider
|
||||
{
|
||||
public string GetBinPathForProduct(ProductFlags productFlag)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public string GetDataPathForProduct(ProductFlags productFlag)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public string GetPathForProduct(ProductFlags productFlag)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public string GetUserPath()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
11
Assets/Tests/TestPathProvider.cs.meta
Normal file
11
Assets/Tests/TestPathProvider.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 87869e2ff0e378845be76ec727d197d0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1
TestAssets/README.md
Normal file
1
TestAssets/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
Resources made specifically for unit testing go here.
|
BIN
TestAssets/TestPackage.package
Normal file
BIN
TestAssets/TestPackage.package
Normal file
Binary file not shown.
Loading…
Reference in a new issue