Refactor asset streaming, error handling, and unit tests
- 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
This commit is contained in:
52
src/Test/Ghost.UnitTest/MockingEnvironment/MockingFence.cs
Normal file
52
src/Test/Ghost.UnitTest/MockingEnvironment/MockingFence.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user