Skip to content

Commit ddc1e8a

Browse files
committed
Test collection initialization
1 parent d9fa7dc commit ddc1e8a

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

Tests/Resources/vmaptest1.dmx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- dmx encoding keyvalues2 4 format vmap 29 -->
2+
"$prefix_element$"
3+
{
4+
"map_asset_references" "string_array" [ ]
5+
}
6+
"CMapRoot"
7+
{
8+
"id" "elementid" "19f231ba-3ad6-4d36-b9d3-b3ae84c4fb69"
9+
"name" "string" "root"
10+
"isprefab" "bool" "0"
11+
"showgrid" "bool" "1"
12+
"snaprotationangle" "int" "15"
13+
"gridspacing" "int" "64"
14+
"show3dgrid" "bool" "1"
15+
"itemFile" "bool" "1"
16+
"world" "CMapWorld"
17+
{
18+
"id" "elementid" "3405a56b-2a71-48f6-8128-e9c82446b712"
19+
"name" "string" "world"
20+
}
21+
}

Tests/Tests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Datamodel;
99
using System.Numerics;
1010
using DM = Datamodel.Datamodel;
11+
using System.Text;
1112

1213
namespace Datamodel_Tests
1314
{
@@ -234,6 +235,34 @@ protected DM Create(string encoding, int version, bool memory_save = false)
234235
[TestFixture]
235236
public class Functionality : DatamodelTests
236237
{
238+
[Test]
239+
public void Create_Datamodel_Vmap()
240+
{
241+
using var datamodel = new DM("vmap", 29);
242+
datamodel.PrefixAttributes.Add("map_asset_references", new List<string>());
243+
datamodel.Root = new Element(datamodel, "root", classNameOverride: "CMapRoot")
244+
{
245+
["isprefab"] = false,
246+
["showgrid"] = true,
247+
["snaprotationangle"] = 15,
248+
["gridspacing"] = 64,
249+
["show3dgrid"] = true,
250+
["itemFile"] = true,
251+
["world"] = new Element(datamodel, "world", classNameOverride: "CMapWorld"),
252+
};
253+
254+
using var stream = new MemoryStream();
255+
datamodel.Save(stream, "keyvalues2", 4);
256+
Assert.That(stream.Length, Is.GreaterThan(0));
257+
258+
using var actual = DM.Load(Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources", "vmaptest1.dmx"));
259+
260+
//Assert.That(actual.PrefixAttributes.ContainsKey("map_asset_references"), Is.True);
261+
//Assert.That(actual.PrefixAttributes["map_asset_references"], Is.Empty);
262+
Assert.That(actual.Root, Is.Not.Null);
263+
Assert.That(actual.Root["world"], Is.Not.Null);
264+
Assert.That(actual.Root["world"], Is.EqualTo(datamodel.Root["world"]));
265+
}
237266

238267
[Test]
239268
public void Create_Binary_9()

0 commit comments

Comments
 (0)