refactor(store): route MessageStore IsWine probe through IPlatformUtil (F12.1)
MessageStore.Connect used to call Util.IsWine() directly via a DalamudUtil alias, which made the ctor unreachable from the xUnit test AppDomain: any test that allocated a MessageStore tripped a FileNotFoundException on Dalamud.dll before reaching the assertion. The ctor now takes an IPlatformUtil and reads the cached IsWine property. MessageManager passes Plugin.PlatformUtil in. Production behaviour is identical; the test path can now substitute a fake and exercise the SQLite migration logic in isolation.
This commit is contained in:
@@ -52,7 +52,7 @@ internal class MessageManager : IAsyncDisposable
|
|||||||
{
|
{
|
||||||
Plugin = plugin;
|
Plugin = plugin;
|
||||||
|
|
||||||
Store = new MessageStore(DatabasePath());
|
Store = new MessageStore(DatabasePath(), Plugin.PlatformUtil);
|
||||||
|
|
||||||
PendingMessageThread = new Thread(() =>
|
PendingMessageThread = new Thread(() =>
|
||||||
ProcessPendingMessages(PendingThreadCancellationToken.Token)
|
ProcessPendingMessages(PendingThreadCancellationToken.Token)
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ using MessagePack;
|
|||||||
using MessagePack.Formatters;
|
using MessagePack.Formatters;
|
||||||
using MessagePack.Resolvers;
|
using MessagePack.Resolvers;
|
||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
using DalamudUtil = Dalamud.Utility.Util;
|
|
||||||
using Encoding = System.Text.Encoding;
|
using Encoding = System.Text.Encoding;
|
||||||
|
|
||||||
namespace HellionChat;
|
namespace HellionChat;
|
||||||
@@ -137,9 +136,12 @@ internal class MessageStore : IDisposable
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
internal MessageStore(string dbPath)
|
private readonly IPlatformUtil _platformUtil;
|
||||||
|
|
||||||
|
internal MessageStore(string dbPath, IPlatformUtil platformUtil)
|
||||||
{
|
{
|
||||||
DbPath = dbPath;
|
DbPath = dbPath;
|
||||||
|
_platformUtil = platformUtil;
|
||||||
Connection = Connect();
|
Connection = Connect();
|
||||||
Migrate();
|
Migrate();
|
||||||
}
|
}
|
||||||
@@ -166,7 +168,7 @@ internal class MessageStore : IDisposable
|
|||||||
conn.Open();
|
conn.Open();
|
||||||
conn.Execute(@"PRAGMA journal_mode=WAL;");
|
conn.Execute(@"PRAGMA journal_mode=WAL;");
|
||||||
conn.Execute(@"PRAGMA synchronous=NORMAL;");
|
conn.Execute(@"PRAGMA synchronous=NORMAL;");
|
||||||
if (DalamudUtil.IsWine())
|
if (_platformUtil.IsWine)
|
||||||
conn.Execute(@"PRAGMA cache_size = 32768;");
|
conn.Execute(@"PRAGMA cache_size = 32768;");
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user