Files
speckle-sharp-sdk/tests/Speckle.Sdk.Serialization.Tests/Framework/ExceptionSendCacheManager.cs
T
Adam Hathcock 5d07fe0ea0 refactor error handling to no propagate through channels. (#268)
* refactor error handling to no propagate through channels.  Use cancellation to shut down on exception

* don't try to shutdown scheduler when exception happens...handle tokens in a tree

* some cleanup

* ConfigureAwait(false) again

* Add test and clean up exception handling

* fmt

* fixed tests
2025-04-07 11:49:47 +01:00

42 lines
1.1 KiB
C#

using Speckle.Sdk.SQLite;
namespace Speckle.Sdk.Serialization.Tests.Framework;
public class ExceptionSendCacheManager(bool? hasObject = null, int? exceptionsAfter = null) : ISqLiteJsonCacheManager
{
private int _count;
public void Dispose() { }
public IReadOnlyCollection<(string Id, string Json)> GetAllObjects() => throw new NotImplementedException();
public void DeleteObject(string id) => CheckExceptions();
public string? GetObject(string id) => null;
public void SaveObject(string id, string json) => CheckExceptions();
public void UpdateObject(string id, string json) => CheckExceptions();
public void SaveObjects(IEnumerable<(string id, string json)> items) => CheckExceptions();
public bool HasObject(string objectId) => hasObject ?? throw new NotImplementedException();
private void CheckExceptions()
{
if (exceptionsAfter is not null)
{
if (exceptionsAfter.Value > _count)
{
_count++;
}
else
{
throw new Exception("Count exceeded");
}
}
throw new NotImplementedException();
}
}