Files
speckle-sharp-sdk/tests/Speckle.Sdk.Tests.Unit/SQLite/SQLiteJsonExceptionTests.cs
T
Adam Hathcock 465f635142 Add details to sqlite exceptions (#198)
* add ServerObjectManagerFactory

* add usage of a command pool

* add more disposal

* save saving increase

* fix tests

* fixes

* push out concurrency and disposablity

* Add a custom task scheduler

* Better usage, don't wait to enqueue to save to channels

* Completely pre-cal batch size to avoid spinning issues

* Try to fix cache counting

* properly dispose things

* format

* clean up

* adjust count and save on current thread

* move batch it's own file

* update a few packages

* fix build and add batch tests

* revert and format

* Revert "save saving increase"

This reverts commit 3b50c857fb.

* revert change

* adjust and add tests

* Dispose sqlite manager properly

* Make Batch a IMemoryOwner to allow for pooling

* Fix tests

* Upgrade some deps

* try to make tests more explicit

* remove return value

* Add detailed SqLiteJsonCacheException

* details changes
2025-01-09 11:04:14 +00:00

28 lines
788 B
C#

using Microsoft.Data.Sqlite;
using NUnit.Framework;
using Speckle.Sdk.SQLite;
namespace Speckle.Sdk.Tests.Unit.SQLite;
[TestFixture]
public class SqLiteJsonCacheExceptionTests
{
[Test]
public void ExpectedExceptionFires_Void()
{
using var pool = new CacheDbCommandPool("DataSource=:memory:", 1);
Assert.Throws<SqLiteJsonCacheException>(
() => pool.Use(CacheOperation.Get, new Action<SqliteCommand>(_ => throw new SqliteException("test", 1, 1)))
);
}
[Test]
public void ExpectedExceptionFires_Return()
{
using var pool = new CacheDbCommandPool("DataSource=:memory:", 1);
Assert.Throws<SqLiteJsonCacheException>(
() => pool.Use(CacheOperation.Get, new Func<SqliteCommand, bool>(_ => throw new SqliteException("test", 1, 1)))
);
}
}