From e94ab40d5e530fc8cb2a9322d07f853a510da903 Mon Sep 17 00:00:00 2001 From: Joanna May Date: Sat, 6 Jul 2024 13:17:58 -0500 Subject: [PATCH] test: updates tests that need fixing and upgrades to autoinject 2.1.0 --- GameDemo.csproj | 2 +- src/app/App.cs | 2 +- src/game/domain/GameRepo.cs | 2 +- test/src/app/AppTest.cs | 2 +- test/src/game/domain/GameRepoTest.cs | 2 +- test/src/game/state/GameLogic.StateTest.cs | 2 +- test/src/game/state/states/MenuBackdropTest.cs | 2 +- test/src/game/state/states/PlayingTest.cs | 2 +- test/src/in_game_ui/InGameUITest.cs | 2 +- .../in_game_ui/state/InGameUILogicStateTest.cs | 2 +- test/src/player/PlayerTest.cs | 1 + .../state/states/PlayerLogic.State.AliveTest.cs | 2 +- test/src/player_camera/PlayerCameraTest.cs | 15 +++++++++++++++ .../state/PlayerCameraLogic.StateTest.cs | 2 +- 14 files changed, 28 insertions(+), 12 deletions(-) diff --git a/GameDemo.csproj b/GameDemo.csproj index bddd675..9744ad5 100644 --- a/GameDemo.csproj +++ b/GameDemo.csproj @@ -45,7 +45,7 @@ - + diff --git a/src/app/App.cs b/src/app/App.cs index 3a13b50..622603b 100644 --- a/src/app/App.cs +++ b/src/app/App.cs @@ -49,7 +49,7 @@ public partial class App : CanvasLayer, IApp { #endregion Nodes - public void Setup() { + public void Initialize() { Instantiator = new Instantiator(GetTree()); AppRepo = new AppRepo(); AppLogic = new AppLogic(); diff --git a/src/game/domain/GameRepo.cs b/src/game/domain/GameRepo.cs index 73f52d4..ef99f1b 100644 --- a/src/game/domain/GameRepo.cs +++ b/src/game/domain/GameRepo.cs @@ -1,7 +1,7 @@ namespace GameDemo; using System; -using Chickensoft.GoDotCollections; +using Chickensoft.Collections; using Godot; public interface IGameRepo : IDisposable { diff --git a/test/src/app/AppTest.cs b/test/src/app/AppTest.cs index 7842d14..140ab7d 100644 --- a/test/src/app/AppTest.cs +++ b/test/src/app/AppTest.cs @@ -64,7 +64,7 @@ public void Initializes() { _app.AppBinding = _binding; - _app.Setup(); + _app.Initialize(); _app.Instantiator.ShouldBeOfType(); _app.AppRepo.ShouldBeOfType(); diff --git a/test/src/game/domain/GameRepoTest.cs b/test/src/game/domain/GameRepoTest.cs index 4a40d01..856304a 100644 --- a/test/src/game/domain/GameRepoTest.cs +++ b/test/src/game/domain/GameRepoTest.cs @@ -1,6 +1,6 @@ namespace GameDemo.Tests; -using Chickensoft.GoDotCollections; +using Chickensoft.Collections; using Chickensoft.GoDotTest; using Godot; using Moq; diff --git a/test/src/game/state/GameLogic.StateTest.cs b/test/src/game/state/GameLogic.StateTest.cs index d763f59..8233ff4 100644 --- a/test/src/game/state/GameLogic.StateTest.cs +++ b/test/src/game/state/GameLogic.StateTest.cs @@ -1,6 +1,6 @@ namespace GameDemo.Tests; -using Chickensoft.GoDotCollections; +using Chickensoft.Collections; using Chickensoft.GoDotTest; using Chickensoft.Introspection; using Chickensoft.LogicBlocks; diff --git a/test/src/game/state/states/MenuBackdropTest.cs b/test/src/game/state/states/MenuBackdropTest.cs index 306d558..65b7e3f 100644 --- a/test/src/game/state/states/MenuBackdropTest.cs +++ b/test/src/game/state/states/MenuBackdropTest.cs @@ -1,7 +1,7 @@ namespace GameDemo.Tests; using System.Linq; -using Chickensoft.GoDotCollections; +using Chickensoft.Collections; using Chickensoft.GoDotTest; using Chickensoft.LogicBlocks; using Godot; diff --git a/test/src/game/state/states/PlayingTest.cs b/test/src/game/state/states/PlayingTest.cs index 633ae6c..653f29c 100644 --- a/test/src/game/state/states/PlayingTest.cs +++ b/test/src/game/state/states/PlayingTest.cs @@ -1,7 +1,7 @@ namespace GameDemo.Tests; using System.Linq; -using Chickensoft.GoDotCollections; +using Chickensoft.Collections; using Chickensoft.GoDotTest; using Chickensoft.LogicBlocks; using Godot; diff --git a/test/src/in_game_ui/InGameUITest.cs b/test/src/in_game_ui/InGameUITest.cs index e832cca..4b17c9c 100644 --- a/test/src/in_game_ui/InGameUITest.cs +++ b/test/src/in_game_ui/InGameUITest.cs @@ -1,7 +1,7 @@ namespace GameDemo.Tests; using Chickensoft.AutoInject; -using Chickensoft.GoDotCollections; +using Chickensoft.Collections; using Chickensoft.GodotNodeInterfaces; using Chickensoft.GoDotTest; using Godot; diff --git a/test/src/in_game_ui/state/InGameUILogicStateTest.cs b/test/src/in_game_ui/state/InGameUILogicStateTest.cs index 0efeb6f..136cfdc 100644 --- a/test/src/in_game_ui/state/InGameUILogicStateTest.cs +++ b/test/src/in_game_ui/state/InGameUILogicStateTest.cs @@ -1,6 +1,6 @@ namespace GameDemo.Tests; -using Chickensoft.GoDotCollections; +using Chickensoft.Collections; using Chickensoft.GoDotTest; using Chickensoft.LogicBlocks; using Godot; diff --git a/test/src/player/PlayerTest.cs b/test/src/player/PlayerTest.cs index 49f6e3f..1ed5538 100644 --- a/test/src/player/PlayerTest.cs +++ b/test/src/player/PlayerTest.cs @@ -211,6 +211,7 @@ public void Loads() { var chunk = new Mock>(); var logic = new PlayerLogic(); + logic.Set(_appRepo.Object); logic.Start(); var data = new PlayerData { diff --git a/test/src/player/state/states/PlayerLogic.State.AliveTest.cs b/test/src/player/state/states/PlayerLogic.State.AliveTest.cs index 3ff8807..ce04426 100644 --- a/test/src/player/state/states/PlayerLogic.State.AliveTest.cs +++ b/test/src/player/state/states/PlayerLogic.State.AliveTest.cs @@ -1,6 +1,6 @@ namespace GameDemo.Tests; -using Chickensoft.GoDotCollections; +using Chickensoft.Collections; using Chickensoft.GoDotTest; using Chickensoft.Introspection; using Chickensoft.LogicBlocks; diff --git a/test/src/player_camera/PlayerCameraTest.cs b/test/src/player_camera/PlayerCameraTest.cs index 0bb8a89..464734e 100644 --- a/test/src/player_camera/PlayerCameraTest.cs +++ b/test/src/player_camera/PlayerCameraTest.cs @@ -2,6 +2,7 @@ namespace GameDemo.Tests; using System.Threading.Tasks; using Chickensoft.AutoInject; +using Chickensoft.Collections; using Chickensoft.GodotNodeInterfaces; using Chickensoft.GoDotTest; using Chickensoft.GodotTestDriver; @@ -204,6 +205,8 @@ public void Saves() { var chunk = new Mock>(); + _playerCam.CameraLogic.Get().ShouldNotBeNull(); + var data = _playerCam.PlayerCameraChunk.OnSave(chunk.Object); data.GlobalTransform.ShouldBe(_playerCam.GlobalTransform); @@ -219,6 +222,18 @@ public void Loads() { var chunk = new Mock>(); var logic = new PlayerCameraLogic(); + _gameRepo.Setup(g => g.IsMouseCaptured).Returns(new AutoProp(false)); + _gameRepo.Setup(g => g.PlayerGlobalPosition) + .Returns(new AutoProp(Vector3.Zero)); + + logic.Set(_gameRepo.Object); + logic.Set(new PlayerCameraLogic.Data { + TargetPosition = Vector3.Zero, + TargetAngleHorizontal = 0f, + TargetAngleVertical = 0f, + TargetOffset = Vector3.Zero + }); + logic.Start(); var data = new PlayerCameraData { diff --git a/test/src/player_camera/state/PlayerCameraLogic.StateTest.cs b/test/src/player_camera/state/PlayerCameraLogic.StateTest.cs index 2863eb3..bdf70ca 100644 --- a/test/src/player_camera/state/PlayerCameraLogic.StateTest.cs +++ b/test/src/player_camera/state/PlayerCameraLogic.StateTest.cs @@ -1,6 +1,6 @@ namespace GameDemo.Tests; -using Chickensoft.GoDotCollections; +using Chickensoft.Collections; using Chickensoft.GoDotTest; using Chickensoft.LogicBlocks; using Godot;