-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathHandPointAtStaleResetShould.cs
More file actions
92 lines (72 loc) · 2.8 KB
/
Copy pathHandPointAtStaleResetShould.cs
File metadata and controls
92 lines (72 loc) · 2.8 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
81
82
83
84
85
86
87
88
89
90
91
92
using Arch.Core;
using DCL.Character.CharacterMotion.Components;
using DCL.Character.CharacterMotion.Systems;
using DCL.Character.Components;
using DCL.CharacterCamera;
using DCL.CharacterMotion.Components;
using DCL.Utilities;
using ECS.SceneLifeCycle;
using ECS.TestSuite;
using NSubstitute;
using NUnit.Framework;
using SceneRunner.Scene;
using System.Threading;
using UnityEngine;
namespace DCL.Character.CharacterMotion.Tests
{
public class HandPointAtStaleResetShould : UnitySystemTestBase<HandPointAtSystem>
{
private static readonly Vector3 STALE_TARGET = new (1234f, 56f, 7890f);
private ReactiveProperty<ISceneFacade?> currentScene = null!;
[SetUp]
public void SetUp()
{
world.Create(new CameraComponent());
currentScene = new ReactiveProperty<ISceneFacade?>(Substitute.For<ISceneFacade>());
var scenesCache = Substitute.For<IScenesCache>();
scenesCache.CurrentScene.Returns(currentScene);
system = new HandPointAtSystem(world, scenesCache);
system.Initialize();
}
[Test]
public void StopPointingWhileTeleporting()
{
Entity player = CreatePointingPlayer(
new PlayerTeleportIntent(null, Vector2Int.zero, Vector3.zero, CancellationToken.None));
system!.Update(0.1f);
Assert.That(world.Get<HandPointAtComponent>(player).IsPointing, Is.False);
}
[Test]
public void StopPointingWhenCurrentSceneIsLost()
{
Entity player = CreatePointingPlayer();
currentScene.Value = null;
system!.Update(0.1f);
Assert.That(world.Get<HandPointAtComponent>(player).IsPointing, Is.False);
}
[Test]
public void KeepPointingWhenCurrentSceneChanges()
{
Entity player = CreatePointingPlayer();
currentScene.Value = Substitute.For<ISceneFacade>();
system!.Update(0.1f);
Assert.That(world.Get<HandPointAtComponent>(player).IsPointing, Is.True);
}
[Test]
public void KeepPointingWhenNotTeleporting()
{
Entity player = CreatePointingPlayer();
system!.Update(0.1f);
Assert.That(world.Get<HandPointAtComponent>(player).IsPointing, Is.True);
}
private Entity CreatePointingPlayer() =>
world.Create(
new PlayerComponent(),
new HandPointAtComponent { IsPointing = true, WorldHitPoint = STALE_TARGET });
private Entity CreatePointingPlayer(PlayerTeleportIntent teleportIntent) =>
world.Create(
new PlayerComponent(),
new HandPointAtComponent { IsPointing = true, WorldHitPoint = STALE_TARGET },
teleportIntent);
}
}