CI / build-test (push) Failing after 1m8s
Add MrGameEng.AI utility-AI module; format codebase with CSharpier New MrGameEng.AI module (ResponseCurve, Consideration, UtilityAction, UtilityAi selector, Blackboard) plus CSharpier formatting applied across the whole engine. Documents the CSharpier convention in CLAUDE.md. @
47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Xunit;
|
|
|
|
namespace MrGameEng.Pathfinding.Tests;
|
|
|
|
/// <summary>
|
|
/// Размеры грида фиксируются в конструкторе; «уехавший» грид должен давать
|
|
/// громкую ошибку, а не молчаливое чтение мимо границ.
|
|
/// </summary>
|
|
public class GridResizeTests
|
|
{
|
|
private sealed class ResizableGrid : IPathGrid
|
|
{
|
|
public int Width { get; set; } = 4;
|
|
|
|
public int Height { get; set; } = 4;
|
|
|
|
public bool IsPassable(int x, int y) => true;
|
|
|
|
public float Cost(int x, int y) => 1f;
|
|
}
|
|
|
|
[Fact]
|
|
public void FindPath_AfterGridResize_Throws()
|
|
{
|
|
var grid = new ResizableGrid();
|
|
var pathfinder = new GridPathfinder(grid);
|
|
grid.Width = 8;
|
|
|
|
Assert.Throws<InvalidOperationException>(() =>
|
|
pathfinder.FindPath(new Point(0, 0), new Point(1, 1), [])
|
|
);
|
|
}
|
|
|
|
[Fact]
|
|
public void FlowFieldBuild_AfterGridResize_Throws()
|
|
{
|
|
var grid = new ResizableGrid();
|
|
var builder = new FlowFieldBuilder(grid);
|
|
grid.Height = 8;
|
|
|
|
Assert.Throws<InvalidOperationException>(() =>
|
|
builder.Build([new Point(0, 0)], new FlowField())
|
|
);
|
|
}
|
|
}
|