Files
Cortex_Engine/tests/Engine.Tests/RenderBackendFactoryTests.cs
T
emil28092005 fb6e26a268 feat: modular HAL, Raylib backend, PBR shading, textures, 60 unit tests
- Replace hardcoded SDL3 windowing with IWindow/IInputState/Key abstractions
- Each render backend owns its window (Raylib GLFW, SDL3 for Vulkan)
- Raylib backend: DrawModelEx, custom GLSL shader with Fresnel, ACES
  tonemapping, gamma correction, hemisphere ambient
- Fix backface culling, mesh memory (NativeMemory.Alloc), texture loading
- Camera controllers use backend-agnostic Key enum (inverted yaw/strafe)
- Demo scene: 8 cubes, 7 spheres, torus knot OBJ with checker texture
- Extract ProceduralMesh + MeshMath from Program.cs to Engine.Graphics
- Vulkan backend deferred (compiles, untested, IWindow-compatible)
- 60 unit tests: ObjLoader, camera controllers, AiCommandProcessor,
  RenderBackendFactory, Timing, ProceduralMesh, MeshMath, Transform
- AGENTS.md for opencode integration
2026-06-17 13:49:12 +03:00

42 lines
1.1 KiB
C#

using Engine.Core;
using Engine.Graphics;
namespace Engine.Tests;
public class RenderBackendFactoryTests
{
private sealed class FakeRenderContext : IRenderContext
{
public IWindow Window => null!;
public IRenderer CreateRenderer() => null!;
public void Resize(int width, int height) { }
public void Dispose() { }
}
[Fact]
public void Create_Returns_Registered_Backend()
{
RenderBackendFactory.Register("fake-test", (_, _, _) => new FakeRenderContext());
var ctx = RenderBackendFactory.Create("fake-test", 800, 600, false);
Assert.IsType<FakeRenderContext>(ctx);
}
[Fact]
public void Create_Throws_For_Unknown_Backend()
{
Assert.Throws<NotSupportedException>(() =>
RenderBackendFactory.Create("nonexistent", 800, 600, false));
}
[Fact]
public void Register_Is_Case_Insensitive()
{
RenderBackendFactory.Register("CaseTest", (_, _, _) => new FakeRenderContext());
var ctx = RenderBackendFactory.Create("casetest", 1, 1, false);
Assert.IsType<FakeRenderContext>(ctx);
}
}