Compare commits

..

2 Commits

Author SHA1 Message Date
Bogdan
5d1f79f3a3 Bump FluentMigrator to official 6.2.0
(cherry picked from commit de722539d098ba67a605cc369e55209667760692)
2025-10-30 09:42:29 -05:00
Bogdan
0ef9f4c869 Fix newznab redirect database migration
(cherry picked from commit f67bc52f85fa0677f4cda5b7b7dcb30dfe31468a)
2025-10-30 09:42:03 -05:00
10 changed files with 167 additions and 87 deletions

View File

@@ -5,6 +5,5 @@
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-bsd-crossbuild" value="https://pkgs.dev.azure.com/Servarr/Servarr/_packaging/dotnet-bsd-crossbuild/nuget/v3/index.json" /> <add key="dotnet-bsd-crossbuild" value="https://pkgs.dev.azure.com/Servarr/Servarr/_packaging/dotnet-bsd-crossbuild/nuget/v3/index.json" />
<add key="Mono.Posix.NETStandard" value="https://pkgs.dev.azure.com/Servarr/Servarr/_packaging/Mono.Posix.NETStandard/nuget/v3/index.json" /> <add key="Mono.Posix.NETStandard" value="https://pkgs.dev.azure.com/Servarr/Servarr/_packaging/Mono.Posix.NETStandard/nuget/v3/index.json" />
<add key="FluentMigrator" value="https://pkgs.dev.azure.com/Servarr/Servarr/_packaging/FluentMigrator/nuget/v3/index.json" />
</packageSources> </packageSources>
</configuration> </configuration>

View File

@@ -14,6 +14,7 @@ namespace NzbDrone.Common.Composition
static AssemblyLoader() static AssemblyLoader()
{ {
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ContainerResolveEventHandler); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ContainerResolveEventHandler);
RegisterSQLiteResolver();
} }
public static IList<Assembly> Load(IList<string> assemblyNames) public static IList<Assembly> Load(IList<string> assemblyNames)
@@ -22,10 +23,6 @@ namespace NzbDrone.Common.Composition
toLoad.Add("Prowlarr.Common"); toLoad.Add("Prowlarr.Common");
toLoad.Add(OsInfo.IsWindows ? "Prowlarr.Windows" : "Prowlarr.Mono"); toLoad.Add(OsInfo.IsWindows ? "Prowlarr.Windows" : "Prowlarr.Mono");
var toRegisterResolver = new List<string> { "System.Data.SQLite" };
toRegisterResolver.AddRange(assemblyNames.Intersect(new[] { "Prowlarr.Core" }));
RegisterNativeResolver(toRegisterResolver);
var startupPath = AppDomain.CurrentDomain.BaseDirectory; var startupPath = AppDomain.CurrentDomain.BaseDirectory;
return toLoad return toLoad
@@ -46,46 +43,27 @@ namespace NzbDrone.Common.Composition
return AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyPath); return AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyPath);
} }
public static void RegisterNativeResolver(IEnumerable<string> assemblyNames) public static void RegisterSQLiteResolver()
{ {
foreach (var name in assemblyNames) // This ensures we look for sqlite3 using libsqlite3.so.0 on Linux and not libsqlite3.so which
{ // is less likely to exist.
// This ensures we look for sqlite3 using libsqlite3.so.0 on Linux and not libsqlite3.so which var sqliteAssembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(
// is less likely to exist. Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "System.Data.SQLite.dll"));
var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{name}.dll"));
try try
{ {
NativeLibrary.SetDllImportResolver(assembly, LoadNativeLib); NativeLibrary.SetDllImportResolver(sqliteAssembly, LoadSqliteNativeLib);
} }
catch (InvalidOperationException) catch (InvalidOperationException)
{ {
// This can only be set once per assembly // This can only be set once per assembly
// Catch required for NzbDrone.Host tests // Catch required for NzbDrone.Host tests
}
} }
} }
private static IntPtr LoadNativeLib(string libraryName, Assembly assembly, DllImportSearchPath? dllImportSearchPath) private static IntPtr LoadSqliteNativeLib(string libraryName, Assembly assembly, DllImportSearchPath? dllImportSearchPath)
{ {
ArgumentException.ThrowIfNullOrWhiteSpace(libraryName); var mappedName = OsInfo.IsLinux && libraryName == "sqlite3" ? "libsqlite3.so.0" : libraryName;
var mappedName = libraryName;
if (libraryName is "sqlite3" or "e_sqlite3")
{
if (OsInfo.IsLinux)
{
if (NativeLibrary.TryLoad(libraryName, assembly, dllImportSearchPath, out var libHandle))
{
return libHandle;
}
mappedName = "libsqlite3.so.0";
}
}
return NativeLibrary.Load(mappedName, assembly, dllImportSearchPath); return NativeLibrary.Load(mappedName, assembly, dllImportSearchPath);
} }
} }

View File

@@ -7,7 +7,7 @@ using NzbDrone.Common.Instrumentation;
namespace NzbDrone.Core.Datastore.Migration namespace NzbDrone.Core.Datastore.Migration
{ {
[Maintenance(MigrationStage.BeforeAll, TransactionBehavior.None)] [Maintenance(MigrationStage.BeforeAll, TransactionBehavior.None)]
public class DatabaseEngineVersionCheck : FluentMigrator.Migration public class DatabaseEngineVersionCheck : ForwardOnlyMigration
{ {
protected readonly Logger _logger; protected readonly Logger _logger;
@@ -22,11 +22,6 @@ namespace NzbDrone.Core.Datastore.Migration
IfDatabase("postgres").Execute.WithConnection(LogPostgresVersion); IfDatabase("postgres").Execute.WithConnection(LogPostgresVersion);
} }
public override void Down()
{
// No-op
}
private void LogSqliteVersion(IDbConnection conn, IDbTransaction tran) private void LogSqliteVersion(IDbConnection conn, IDbTransaction tran)
{ {
using (var versionCmd = conn.CreateCommand()) using (var versionCmd = conn.CreateCommand())

View File

@@ -1,5 +1,3 @@
using System.Data;
using Dapper;
using FluentMigrator; using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework; using NzbDrone.Core.Datastore.Migration.Framework;
@@ -10,13 +8,7 @@ namespace NzbDrone.Core.Datastore.Migration
{ {
protected override void MainDbUpgrade() protected override void MainDbUpgrade()
{ {
Execute.WithConnection(UpdateNewznabRedirectSetting); Update.Table("Indexers").Set(new { Redirect = true }).Where(new { Implementation = "Newznab", Redirect = false });
}
private void UpdateNewznabRedirectSetting(IDbConnection conn, IDbTransaction tran)
{
var updateSql = "UPDATE \"Indexers\" SET \"Redirect\" = @Redirect WHERE \"Implementation\" = 'Newznab' AND \"Redirect\" = false";
conn.Execute(updateSql, new { Redirect = true }, transaction: tran);
} }
} }
} }

View File

@@ -6,7 +6,6 @@ using FluentMigrator.Runner.Generators;
using FluentMigrator.Runner.Initialization; using FluentMigrator.Runner.Initialization;
using FluentMigrator.Runner.Processors; using FluentMigrator.Runner.Processors;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog; using NLog;
using NLog.Extensions.Logging; using NLog.Extensions.Logging;
@@ -20,13 +19,10 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
public class MigrationController : IMigrationController public class MigrationController : IMigrationController
{ {
private readonly Logger _logger; private readonly Logger _logger;
private readonly ILoggerProvider _migrationLoggerProvider;
public MigrationController(Logger logger, public MigrationController(Logger logger)
ILoggerProvider migrationLoggerProvider)
{ {
_logger = logger; _logger = logger;
_migrationLoggerProvider = migrationLoggerProvider;
} }
public void Migrate(string connectionString, MigrationContext migrationContext, DatabaseType databaseType) public void Migrate(string connectionString, MigrationContext migrationContext, DatabaseType databaseType)
@@ -35,16 +31,13 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
_logger.Info("*** Migrating {0} ***", connectionString); _logger.Info("*** Migrating {0} ***", connectionString);
ServiceProvider serviceProvider;
var db = databaseType == DatabaseType.SQLite ? "sqlite" : "postgres"; var db = databaseType == DatabaseType.SQLite ? "sqlite" : "postgres";
serviceProvider = new ServiceCollection() var serviceProvider = new ServiceCollection()
.AddLogging(b => b.AddNLog()) .AddLogging(b => b.AddNLog())
.AddFluentMigratorCore() .AddFluentMigratorCore()
.Configure<RunnerOptions>(cfg => cfg.IncludeUntaggedMaintenances = true) .Configure<RunnerOptions>(cfg => cfg.IncludeUntaggedMaintenances = true)
.ConfigureRunner( .ConfigureRunner(builder => builder
builder => builder
.AddPostgres() .AddPostgres()
.AddNzbDroneSQLite() .AddNzbDroneSQLite()
.WithGlobalConnectionString(connectionString) .WithGlobalConnectionString(connectionString)

View File

@@ -1,11 +1,17 @@
using FluentMigrator; using System.Data;
using FluentMigrator;
using FluentMigrator.Builders.Create; using FluentMigrator.Builders.Create;
using FluentMigrator.Builders.Create.Table; using FluentMigrator.Builders.Create.Table;
using FluentMigrator.Runner; using FluentMigrator.Runner;
using FluentMigrator.Runner.BatchParser; using FluentMigrator.Runner.BatchParser;
using FluentMigrator.Runner.Generators;
using FluentMigrator.Runner.Generators.SQLite; using FluentMigrator.Runner.Generators.SQLite;
using FluentMigrator.Runner.Initialization;
using FluentMigrator.Runner.Processors;
using FluentMigrator.Runner.Processors.SQLite; using FluentMigrator.Runner.Processors.SQLite;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace NzbDrone.Core.Datastore.Migration.Framework namespace NzbDrone.Core.Datastore.Migration.Framework
{ {
@@ -16,23 +22,40 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
return expressionRoot.Table(name).WithColumn("Id").AsInt32().PrimaryKey().Identity(); return expressionRoot.Table(name).WithColumn("Id").AsInt32().PrimaryKey().Identity();
} }
public static void AddParameter(this System.Data.IDbCommand command, object value) public static void AddParameter(this IDbCommand command, object value)
{ {
var parameter = command.CreateParameter(); var parameter = command.CreateParameter();
parameter.Value = value; parameter.Value = value;
command.Parameters.Add(parameter); command.Parameters.Add(parameter);
} }
public static IMigrationRunnerBuilder AddNzbDroneSQLite(this IMigrationRunnerBuilder builder) public static IMigrationRunnerBuilder AddNzbDroneSQLite(this IMigrationRunnerBuilder builder, bool binaryGuid = false, bool useStrictTables = false)
{ {
builder.Services builder.Services
.AddTransient<SQLiteBatchParser>() .AddTransient<SQLiteBatchParser>()
.AddScoped<SQLiteDbFactory>() .AddScoped<SQLiteDbFactory>()
.AddScoped<NzbDroneSQLiteProcessor>() .AddScoped<NzbDroneSQLiteProcessor>(sp =>
{
var factory = sp.GetService<SQLiteDbFactory>();
var logger = sp.GetService<ILogger<NzbDroneSQLiteProcessor>>();
var options = sp.GetService<IOptionsSnapshot<ProcessorOptions>>();
var connectionStringAccessor = sp.GetService<IConnectionStringAccessor>();
var sqliteQuoter = new SQLiteQuoter(false);
return new NzbDroneSQLiteProcessor(factory, sp.GetService<SQLiteGenerator>(), logger, options, connectionStringAccessor, sp, sqliteQuoter);
})
.AddScoped<ISQLiteTypeMap>(_ => new NzbDroneSQLiteTypeMap(useStrictTables))
.AddScoped<IMigrationProcessor>(sp => sp.GetRequiredService<NzbDroneSQLiteProcessor>()) .AddScoped<IMigrationProcessor>(sp => sp.GetRequiredService<NzbDroneSQLiteProcessor>())
.AddScoped<SQLiteQuoter>() .AddScoped(
.AddScoped<SQLiteGenerator>() sp =>
{
var typeMap = sp.GetRequiredService<ISQLiteTypeMap>();
return new SQLiteGenerator(
new SQLiteQuoter(binaryGuid),
typeMap,
new OptionsWrapper<GeneratorOptions>(new GeneratorOptions()));
})
.AddScoped<IMigrationGenerator>(sp => sp.GetRequiredService<SQLiteGenerator>()); .AddScoped<IMigrationGenerator>(sp => sp.GetRequiredService<SQLiteGenerator>());
return builder; return builder;
} }
} }

View File

@@ -15,6 +15,8 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
{ {
public class NzbDroneSQLiteProcessor : SQLiteProcessor public class NzbDroneSQLiteProcessor : SQLiteProcessor
{ {
private readonly SQLiteQuoter _quoter;
public NzbDroneSQLiteProcessor(SQLiteDbFactory factory, public NzbDroneSQLiteProcessor(SQLiteDbFactory factory,
SQLiteGenerator generator, SQLiteGenerator generator,
ILogger<NzbDroneSQLiteProcessor> logger, ILogger<NzbDroneSQLiteProcessor> logger,
@@ -24,6 +26,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
SQLiteQuoter quoter) SQLiteQuoter quoter)
: base(factory, generator, logger, options, connectionStringAccessor, serviceProvider, quoter) : base(factory, generator, logger, options, connectionStringAccessor, serviceProvider, quoter)
{ {
_quoter = quoter;
} }
public override void Process(AlterColumnExpression expression) public override void Process(AlterColumnExpression expression)
@@ -35,7 +38,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
if (columnIndex == -1) if (columnIndex == -1)
{ {
throw new ApplicationException(string.Format("Column {0} does not exist on table {1}.", expression.Column.Name, expression.TableName)); throw new ApplicationException($"Column {expression.Column.Name} does not exist on table {expression.TableName}.");
} }
columnDefinitions[columnIndex] = expression.Column; columnDefinitions[columnIndex] = expression.Column;
@@ -45,6 +48,28 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
ProcessAlterTable(tableDefinition); ProcessAlterTable(tableDefinition);
} }
public override void Process(AlterDefaultConstraintExpression expression)
{
var tableDefinition = GetTableSchema(expression.TableName);
var columnDefinitions = tableDefinition.Columns.ToList();
var columnIndex = columnDefinitions.FindIndex(c => c.Name == expression.ColumnName);
if (columnIndex == -1)
{
throw new ApplicationException($"Column {expression.ColumnName} does not exist on table {expression.TableName}.");
}
var changedColumn = columnDefinitions[columnIndex];
changedColumn.DefaultValue = expression.DefaultValue;
columnDefinitions[columnIndex] = changedColumn;
tableDefinition.Columns = columnDefinitions;
ProcessAlterTable(tableDefinition);
}
public override void Process(DeleteColumnExpression expression) public override void Process(DeleteColumnExpression expression)
{ {
var tableDefinition = GetTableSchema(expression.TableName); var tableDefinition = GetTableSchema(expression.TableName);
@@ -62,7 +87,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
if (columnsToRemove.Any()) if (columnsToRemove.Any())
{ {
throw new ApplicationException(string.Format("Column {0} does not exist on table {1}.", columnsToRemove.First(), expression.TableName)); throw new ApplicationException($"Column {columnsToRemove.First()} does not exist on table {expression.TableName}.");
} }
ProcessAlterTable(tableDefinition); ProcessAlterTable(tableDefinition);
@@ -78,12 +103,12 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
if (columnIndex == -1) if (columnIndex == -1)
{ {
throw new ApplicationException(string.Format("Column {0} does not exist on table {1}.", expression.OldName, expression.TableName)); throw new ApplicationException($"Column {expression.OldName} does not exist on table {expression.TableName}.");
} }
if (columnDefinitions.Any(c => c.Name == expression.NewName)) if (columnDefinitions.Any(c => c.Name == expression.NewName))
{ {
throw new ApplicationException(string.Format("Column {0} already exists on table {1}.", expression.NewName, expression.TableName)); throw new ApplicationException($"Column {expression.NewName} already exists on table {expression.TableName}.");
} }
oldColumnDefinitions[columnIndex] = (ColumnDefinition)columnDefinitions[columnIndex].Clone(); oldColumnDefinitions[columnIndex] = (ColumnDefinition)columnDefinitions[columnIndex].Clone();
@@ -128,21 +153,20 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
} }
// What is the cleanest way to do this? Add function to Generator? // What is the cleanest way to do this? Add function to Generator?
var quoter = new SQLiteQuoter(); var columnsToInsert = string.Join(", ", tableDefinition.Columns.Select(c => _quoter.QuoteColumnName(c.Name)));
var columnsToInsert = string.Join(", ", tableDefinition.Columns.Select(c => quoter.QuoteColumnName(c.Name))); var columnsToFetch = string.Join(", ", (oldColumnDefinitions ?? tableDefinition.Columns).Select(c => _quoter.QuoteColumnName(c.Name)));
var columnsToFetch = string.Join(", ", (oldColumnDefinitions ?? tableDefinition.Columns).Select(c => quoter.QuoteColumnName(c.Name)));
Process(new CreateTableExpression() { TableName = tempTableName, Columns = tableDefinition.Columns.ToList() }); Process(new CreateTableExpression { TableName = tempTableName, Columns = tableDefinition.Columns.ToList() });
Process(string.Format("INSERT INTO {0} ({1}) SELECT {2} FROM {3}", quoter.QuoteTableName(tempTableName), columnsToInsert, columnsToFetch, quoter.QuoteTableName(tableName))); Process($"INSERT INTO {_quoter.QuoteTableName(tempTableName)} ({columnsToInsert}) SELECT {columnsToFetch} FROM {_quoter.QuoteTableName(tableName)}");
Process(new DeleteTableExpression() { TableName = tableName }); Process(new DeleteTableExpression { TableName = tableName });
Process(new RenameTableExpression() { OldName = tempTableName, NewName = tableName }); Process(new RenameTableExpression { OldName = tempTableName, NewName = tableName });
foreach (var index in tableDefinition.Indexes) foreach (var index in tableDefinition.Indexes)
{ {
Process(new CreateIndexExpression() { Index = index }); Process(new CreateIndexExpression { Index = index });
} }
} }
} }

View File

@@ -0,0 +1,76 @@
using System.Data;
using FluentMigrator.Runner.Generators.Base;
using FluentMigrator.Runner.Generators.SQLite;
namespace NzbDrone.Core.Datastore.Migration.Framework;
// Based on https://github.com/fluentmigrator/fluentmigrator/blob/v6.2.0/src/FluentMigrator.Runner.SQLite/Generators/SQLite/SQLiteTypeMap.cs
public sealed class NzbDroneSQLiteTypeMap : TypeMapBase, ISQLiteTypeMap
{
public bool UseStrictTables { get; }
public NzbDroneSQLiteTypeMap(bool useStrictTables = false)
{
UseStrictTables = useStrictTables;
SetupTypeMaps();
}
// Must be kept in sync with upstream
protected override void SetupTypeMaps()
{
SetTypeMap(DbType.Binary, "BLOB");
SetTypeMap(DbType.Byte, "INTEGER");
SetTypeMap(DbType.Int16, "INTEGER");
SetTypeMap(DbType.Int32, "INTEGER");
SetTypeMap(DbType.Int64, "INTEGER");
SetTypeMap(DbType.SByte, "INTEGER");
SetTypeMap(DbType.UInt16, "INTEGER");
SetTypeMap(DbType.UInt32, "INTEGER");
SetTypeMap(DbType.UInt64, "INTEGER");
if (!UseStrictTables)
{
SetTypeMap(DbType.Currency, "NUMERIC");
SetTypeMap(DbType.Decimal, "NUMERIC");
SetTypeMap(DbType.Double, "NUMERIC");
SetTypeMap(DbType.Single, "NUMERIC");
SetTypeMap(DbType.VarNumeric, "NUMERIC");
SetTypeMap(DbType.Date, "DATETIME");
SetTypeMap(DbType.DateTime, "DATETIME");
SetTypeMap(DbType.DateTime2, "DATETIME");
SetTypeMap(DbType.Time, "DATETIME");
SetTypeMap(DbType.Guid, "UNIQUEIDENTIFIER");
// Custom so that we can use DateTimeOffset in Postgres for appropriate DB typing
SetTypeMap(DbType.DateTimeOffset, "DATETIME");
}
else
{
SetTypeMap(DbType.Currency, "TEXT");
SetTypeMap(DbType.Decimal, "TEXT");
SetTypeMap(DbType.Double, "REAL");
SetTypeMap(DbType.Single, "REAL");
SetTypeMap(DbType.VarNumeric, "TEXT");
SetTypeMap(DbType.Date, "TEXT");
SetTypeMap(DbType.DateTime, "TEXT");
SetTypeMap(DbType.DateTime2, "TEXT");
SetTypeMap(DbType.Time, "TEXT");
SetTypeMap(DbType.Guid, "TEXT");
// Custom so that we can use DateTimeOffset in Postgres for appropriate DB typing
SetTypeMap(DbType.DateTimeOffset, "TEXT");
}
SetTypeMap(DbType.AnsiString, "TEXT");
SetTypeMap(DbType.String, "TEXT");
SetTypeMap(DbType.AnsiStringFixedLength, "TEXT");
SetTypeMap(DbType.StringFixedLength, "TEXT");
SetTypeMap(DbType.Boolean, "INTEGER");
}
public override string GetTypeMap(DbType type, int? size, int? precision)
{
return base.GetTypeMap(type, size: null, precision: null);
}
}

View File

@@ -13,9 +13,9 @@
<PackageReference Include="NLog.Targets.Syslog" Version="7.0.0" /> <PackageReference Include="NLog.Targets.Syslog" Version="7.0.0" />
<PackageReference Include="Npgsql" Version="9.0.3" /> <PackageReference Include="Npgsql" Version="9.0.3" />
<PackageReference Include="Polly" Version="8.6.4" /> <PackageReference Include="Polly" Version="8.6.4" />
<PackageReference Include="Servarr.FluentMigrator.Runner" Version="3.3.2.9" /> <PackageReference Include="FluentMigrator.Runner" Version="6.2.0" />
<PackageReference Include="Servarr.FluentMigrator.Runner.Postgres" Version="3.3.2.9" /> <PackageReference Include="FluentMigrator.Runner.Postgres" Version="6.2.0" />
<PackageReference Include="Servarr.FluentMigrator.Runner.SQLite" Version="3.3.2.9" /> <PackageReference Include="FluentMigrator.Runner.SQLite" Version="6.2.0" />
<PackageReference Include="System.Drawing.Common" Version="8.0.19" /> <PackageReference Include="System.Drawing.Common" Version="8.0.19" />
<PackageReference Include="System.Memory" Version="4.6.3" /> <PackageReference Include="System.Memory" Version="4.6.3" />
<PackageReference Include="System.ServiceModel.Syndication" Version="8.0.0" /> <PackageReference Include="System.ServiceModel.Syndication" Version="8.0.0" />

View File

@@ -51,7 +51,7 @@ namespace NzbDrone.Test.Common.AutoMoq
if (behavior != MockBehavior.Default && mock.Behavior == MockBehavior.Default) if (behavior != MockBehavior.Default && mock.Behavior == MockBehavior.Default)
{ {
throw new InvalidOperationException("Unable to change be behaviour of an existing mock."); throw new InvalidOperationException("Unable to change be behaviour of a an existing mock.");
} }
return mock; return mock;
@@ -139,7 +139,7 @@ namespace NzbDrone.Test.Common.AutoMoq
LoadPlatformLibrary(); LoadPlatformLibrary();
AssemblyLoader.RegisterNativeResolver(new[] { "System.Data.SQLite", "Prowlarr.Core" }); AssemblyLoader.RegisterSQLiteResolver();
} }
private Mock<T> TheRegisteredMockForThisType<T>(Type type) private Mock<T> TheRegisteredMockForThisType<T>(Type type)