- Add new compile-time constants and update package versions - Refactor AssetEntry upload logic to return Result and propagate errors - Enhance error handling in ResourceStreamingProcessor uploads - Make ResourceStreamingContext a readonly struct - Implement IDisposable and finalizers for resource cleanup - Overhaul AssetManagerTest with async tests and improved mocks - Add mock implementations for graphics interfaces for testing - Refactor MockingCommandBuffer and MockingResourceDatabase for better simulation - Update internals visibility for unit testing
53 lines
1.0 KiB
C#
53 lines
1.0 KiB
C#
using Ghost.Graphics.RHI;
|
|
|
|
namespace Ghost.UnitTest.MockingEnvironment;
|
|
|
|
internal class MockingFence : IFence
|
|
{
|
|
private readonly AutoResetEvent _fenceEvent;
|
|
|
|
private ulong _currentValue;
|
|
|
|
public ulong CompletedValue => _currentValue;
|
|
|
|
public nint WaitHandle => _fenceEvent.SafeWaitHandle.DangerousGetHandle();
|
|
|
|
public string Name
|
|
{
|
|
get; set;
|
|
} = "MockingFence";
|
|
|
|
public MockingFence(ulong initialValue)
|
|
{
|
|
_fenceEvent = new AutoResetEvent(false);
|
|
_currentValue = initialValue;
|
|
}
|
|
|
|
public void Signal(ulong value)
|
|
{
|
|
if (value > _currentValue)
|
|
{
|
|
_currentValue = value;
|
|
_fenceEvent.Set();
|
|
}
|
|
}
|
|
|
|
public void WaitForValue(ulong value)
|
|
{
|
|
if (value > _currentValue)
|
|
{
|
|
_fenceEvent.WaitOne();
|
|
}
|
|
}
|
|
|
|
public Task WaitForValueAsync(ulong value)
|
|
{
|
|
return Task.Run(() => { WaitForValue(value); });
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_fenceEvent.Dispose();
|
|
}
|
|
}
|