-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathECSReloadSceneShould.cs
More file actions
80 lines (67 loc) · 3.11 KB
/
Copy pathECSReloadSceneShould.cs
File metadata and controls
80 lines (67 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using DCL.Ipfs;
using ECS.SceneLifeCycle;
using NUnit.Framework;
namespace DCL.SceneLifeCycle.Tests
{
public class ECSReloadSceneShould
{
[Test]
public void TreatDefinitionWithoutManifestAsRawGltf()
{
//Arrange: no asset-bundle manifest -> the container cache is keyed by the bare hash
SceneEntityDefinition definition = CreateDefinition();
//Act & Assert
Assert.That(ECSReloadScene.IsRawGltfModel(definition, "b64-somehash"), Is.True);
}
[Test]
public void NotTreatMissingDefinitionOrEmptyHashAsRawGltf()
{
SceneEntityDefinition definition = CreateDefinition();
Assert.That(ECSReloadScene.IsRawGltfModel(null, "b64-somehash"), Is.False);
Assert.That(ECSReloadScene.IsRawGltfModel(definition, string.Empty), Is.False);
Assert.That(ECSReloadScene.IsRawGltfModel(definition, null!), Is.False);
}
[Test]
public void ResolveContentHashBySrcIgnoringCase()
{
//Arrange
SceneEntityDefinition definition = CreateDefinition(
new ContentDefinition { file = "models/shark.glb", hash = "b64-content-hash" });
//Act
bool resolved = ECSReloadScene.TryResolveContentHash(definition, "Models/Shark.GLB", out string hash);
//Assert
Assert.That(resolved, Is.True);
Assert.That(hash, Is.EqualTo("b64-content-hash"));
}
[Test]
public void ResolveContentHashWhenSrcUsesWindowsSeparators()
{
//Arrange: content mappings always spell paths with '/', but the local dev server's file
//watcher reports the platform separator — on Windows that is '\'.
SceneEntityDefinition definition = CreateDefinition(
new ContentDefinition { file = "assets/models/out/models/BenchStreet.glb", hash = "b64-content-hash" });
//Act
bool resolved = ECSReloadScene.TryResolveContentHash(definition, @"assets\models\out\models\BenchStreet.glb", out string hash);
//Assert
Assert.That(resolved, Is.True);
Assert.That(hash, Is.EqualTo("b64-content-hash"));
}
[Test]
public void NotResolveContentHashWhenSrcIsUnknownOrMissing()
{
//Arrange
SceneEntityDefinition definition = CreateDefinition(
new ContentDefinition { file = "models/shark.glb", hash = "b64-content-hash" });
//Act & Assert
Assert.That(ECSReloadScene.TryResolveContentHash(definition, "models/monster.glb", out _), Is.False);
Assert.That(ECSReloadScene.TryResolveContentHash(definition, string.Empty, out _), Is.False);
Assert.That(ECSReloadScene.TryResolveContentHash(null, "models/shark.glb", out _), Is.False);
}
private static SceneEntityDefinition CreateDefinition(params ContentDefinition[] content) =>
new ("test-scene", new SceneMetadata())
{
pointers = new[] { "0,0" },
content = content,
};
}
}