Remove obsolete project files for MrGameEng.AI, MrGameEng.Assets, MrGameEng.Atlases, and MrGameEng.Collisions modules. Introduce new AssetManager and related classes for asset loading and management, including support for texture atlases and mod definitions. Enhance mod loading capabilities with DefDatabase and LanguageManager for JSON-based definitions and localization. Implement a shelf packing algorithm for efficient texture atlas creation.
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using MrGameEng.AI;
|
||||
using Xunit;
|
||||
|
||||
namespace MrGameEng.AI.Tests;
|
||||
|
||||
public class BlackboardTests
|
||||
{
|
||||
[Fact]
|
||||
public void SetThenTryGet_RoundTripsTypedValues()
|
||||
{
|
||||
var board = new Blackboard();
|
||||
board.Set("target", new Vector2(3f, 4f));
|
||||
|
||||
Assert.True(board.TryGet<Vector2>("target", out var value));
|
||||
Assert.Equal(new Vector2(3f, 4f), value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryGet_ReturnsFalse_OnMissingKeyOrTypeMismatch()
|
||||
{
|
||||
var board = new Blackboard();
|
||||
board.Set("count", 5);
|
||||
|
||||
Assert.False(board.TryGet<int>("missing", out _));
|
||||
Assert.False(board.TryGet<string>("count", out _)); // wrong type
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetOrDefault_FallsBackWhenAbsent()
|
||||
{
|
||||
var board = new Blackboard();
|
||||
|
||||
Assert.Equal(42, board.GetOrDefault("hp", 42));
|
||||
board.Set("hp", 7);
|
||||
Assert.Equal(7, board.GetOrDefault("hp", 42));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Set_OverwritesExistingValue()
|
||||
{
|
||||
var board = new Blackboard();
|
||||
board.Set("k", 1);
|
||||
board.Set("k", 2);
|
||||
|
||||
Assert.Equal(2, board.GetOrDefault("k", 0));
|
||||
Assert.Equal(1, board.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveAndClear_DropKeys()
|
||||
{
|
||||
var board = new Blackboard();
|
||||
board.Set("a", 1);
|
||||
board.Set("b", 2);
|
||||
|
||||
Assert.True(board.Remove("a"));
|
||||
Assert.False(board.Remove("a"));
|
||||
Assert.True(board.Has("b"));
|
||||
|
||||
board.Clear();
|
||||
Assert.Equal(0, board.Count);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user