acdream/tests/AcDream.App.Tests/Input/LocalPlayerOutboundCombatStyleTests.cs
Erik 476c2e6de1 test(app): freeze GameWindow lifecycle boundaries
Pin the accepted startup, input, frame, resize, shutdown, and native-window order before Slice 8 moves those edges, while deleting only unread duplicate state and test-only GameWindow facades.

Co-authored-by: Codex <codex@openai.com>
2026-07-22 09:27:55 +02:00

50 lines
1.7 KiB
C#

using System.Buffers.Binary;
using AcDream.App.Input;
using AcDream.Core.Net.Messages;
using AcDream.Core.Net.Packets;
using AcDream.Core.Physics;
namespace AcDream.App.Tests.Input;
public sealed class LocalPlayerOutboundCombatStyleTests
{
[Theory]
[InlineData(0x8000003Cu)] // HandCombat
[InlineData(0x8000003Eu)] // Magic
[InlineData(0x8000003Fu)] // BowCombat
[InlineData(0x80000041u)] // CrossbowCombat
public void CaptureAndBuild_PreservesCanonicalRawCombatStyle(uint combatStyle)
{
var controller = new PlayerMovementController(new PhysicsEngine());
controller.Motion.RawState.CurrentStyle = combatStyle;
MovementResult movement = controller.CaptureMovementResult(
mouseLookEvent: false);
RawMotionState outbound = LocalPlayerOutboundController.BuildRawMotionState(
movement);
Assert.Equal(combatStyle, movement.CurrentStyle);
Assert.Equal(combatStyle, outbound.CurrentStyle);
var writer = new PacketWriter(16);
RawMotionStatePacker.Pack(writer, outbound);
byte[] bytes = writer.ToArray();
uint flags = BinaryPrimitives.ReadUInt32LittleEndian(bytes);
Assert.NotEqual(0u, flags & 0x2u);
Assert.Equal(
combatStyle,
BinaryPrimitives.ReadUInt32LittleEndian(bytes.AsSpan(4)));
}
[Fact]
public void CaptureAndBuild_NonCombatRetainsRetailDefault()
{
var controller = new PlayerMovementController(new PhysicsEngine());
RawMotionState outbound = LocalPlayerOutboundController.BuildRawMotionState(
controller.CaptureMovementResult(mouseLookEvent: false));
Assert.Equal(RawMotionState.Default.CurrentStyle, outbound.CurrentStyle);
}
}