* Stylecop Rules and Fixes
This commit is contained in:
Qstick
2020-01-03 07:49:24 -05:00
committed by GitHub
parent 63d669178d
commit f77a2feeef
1307 changed files with 8704 additions and 7404 deletions
+7 -7
View File
@@ -5,12 +5,12 @@ using NzbDrone.Common.Cloud;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Http;
using NzbDrone.Common.Http.Dispatchers;
using NzbDrone.Common.TPL;
using NzbDrone.Test.Common;
using NzbDrone.Common.Http.Proxy;
using NzbDrone.Core.Http;
using NzbDrone.Common.TPL;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Http;
using NzbDrone.Core.MetadataSource;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.Framework
{
@@ -19,8 +19,8 @@ namespace NzbDrone.Core.Test.Framework
protected void UseRealHttp()
{
Mocker.GetMock<IPlatformInfo>().SetupGet(c => c.Version).Returns(new Version("3.0.0"));
Mocker.GetMock<IOsInfo>().SetupGet(c=>c.Version).Returns("1.0.0");
Mocker.GetMock<IOsInfo>().SetupGet(c=>c.Name).Returns("TestOS");
Mocker.GetMock<IOsInfo>().SetupGet(c => c.Version).Returns("1.0.0");
Mocker.GetMock<IOsInfo>().SetupGet(c => c.Name).Returns("TestOS");
Mocker.SetConstant<IHttpProxySettingsProvider>(new HttpProxySettingsProvider(Mocker.Resolve<ConfigService>()));
Mocker.SetConstant<ICreateManagedWebProxy>(new ManagedWebProxyFactory(Mocker.Resolve<CacheManager>()));
@@ -31,7 +31,8 @@ namespace NzbDrone.Core.Test.Framework
}
}
public abstract class CoreTest<TSubject> : CoreTest where TSubject : class
public abstract class CoreTest<TSubject> : CoreTest
where TSubject : class
{
private TSubject _subject;
@@ -52,7 +53,6 @@ namespace NzbDrone.Core.Test.Framework
return _subject;
}
}
}
}
+5 -4
View File
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.IO;
using System.Linq;
using FluentMigrator.Runner;
using Marr.Data;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
@@ -43,7 +41,6 @@ namespace NzbDrone.Core.Test.Framework
return _subject;
}
}
}
@@ -59,7 +56,9 @@ namespace NzbDrone.Core.Test.Framework
get
{
if (_db == null)
{
throw new InvalidOperationException("Test object database doesn't exists. Make sure you call WithRealDb() if you intend to use an actual database.");
}
return _db;
}
@@ -80,6 +79,7 @@ namespace NzbDrone.Core.Test.Framework
Mocker.SetConstant<IMainDatabase>(mainDb);
break;
}
case MigrationType.Log:
{
var logDb = new LogDatabase(database);
@@ -87,6 +87,7 @@ namespace NzbDrone.Core.Test.Framework
Mocker.SetConstant<ILogDatabase>(logDb);
break;
}
default:
{
throw new ArgumentException("Invalid MigrationType");
@@ -128,7 +129,7 @@ namespace NzbDrone.Core.Test.Framework
GC.Collect();
GC.WaitForPendingFinalizers();
SQLiteConnection.ClearAllPools();
if (TestFolderInfo != null)
{
DeleteTempFolder(TestFolderInfo.AppDataFolder);
@@ -11,7 +11,8 @@ namespace NzbDrone.Core.Test.Framework
public interface IDirectDataMapper
{
List<Dictionary<string, object>> Query(string sql);
List<T> Query<T>(string sql) where T : new();
List<T> Query<T>(string sql)
where T : new();
T QueryScalar<T>(string sql);
}
@@ -56,7 +57,8 @@ namespace NzbDrone.Core.Test.Framework
return dataTable.Rows.Cast<DataRow>().Select(MapToDictionary).ToList();
}
public List<T> Query<T>(string sql) where T : new()
public List<T> Query<T>(string sql)
where T : new()
{
var dataTable = GetDataTable(sql);
@@ -94,7 +96,8 @@ namespace NzbDrone.Core.Test.Framework
return item;
}
protected T MapToObject<T>(DataRow dataRow) where T : new()
protected T MapToObject<T>(DataRow dataRow)
where T : new()
{
var item = new T();
@@ -117,7 +120,6 @@ namespace NzbDrone.Core.Test.Framework
object value = MapValue(dataRow, i, propertyType);
propertyInfo.SetValue(item, value, null);
}
@@ -1,11 +1,12 @@
using NUnit.Framework;
using System.IO.Abstractions.TestingHelpers;
using System.IO.Abstractions.TestingHelpers;
using NUnit.Framework;
using NzbDrone.Common.Disk;
using Unity.Resolution;
namespace NzbDrone.Core.Test.Framework
{
public abstract class FileSystemTest<TSubject> : CoreTest<TSubject> where TSubject : class
public abstract class FileSystemTest<TSubject> : CoreTest<TSubject>
where TSubject : class
{
protected MockFileSystem FileSystem { get; private set; }
protected IDiskProvider DiskProvider { get; private set; }
@@ -15,9 +16,10 @@ namespace NzbDrone.Core.Test.Framework
{
FileSystem = new MockFileSystem();
DiskProvider = Mocker.Resolve<IDiskProvider>("ActualDiskProvider", new ResolverOverride[] {
DiskProvider = Mocker.Resolve<IDiskProvider>("ActualDiskProvider", new ResolverOverride[]
{
new ParameterOverride("fileSystem", FileSystem)
});
});
}
}
}
@@ -8,7 +8,8 @@ namespace NzbDrone.Core.Test.Framework
{
[Category("DbMigrationTest")]
[Category("DbTest")]
public abstract class MigrationTest<TMigration> : DbTest where TMigration : NzbDroneMigrationBase
public abstract class MigrationTest<TMigration> : DbTest
where TMigration : NzbDroneMigrationBase
{
protected long MigrationVersion
{
@@ -7,20 +7,22 @@ namespace NzbDrone.Core.Test.Framework
{
public static class NBuilderExtensions
{
public static T BuildNew<T>(this ISingleObjectBuilder<T> builder) where T : ModelBase, new()
public static T BuildNew<T>(this ISingleObjectBuilder<T> builder)
where T : ModelBase, new()
{
return builder.With(c => c.Id = 0).Build();
}
public static List<T> BuildList<T>(this IListBuilder<T> builder) where T : ModelBase, new()
public static List<T> BuildList<T>(this IListBuilder<T> builder)
where T : ModelBase, new()
{
return builder.Build().ToList();
}
public static List<T> BuildListOfNew<T>(this IListBuilder<T> builder) where T : ModelBase, new()
public static List<T> BuildListOfNew<T>(this IListBuilder<T> builder)
where T : ModelBase, new()
{
return BuildList<T>(builder.All().With(c => c.Id = 0));
}
}
}
}
@@ -8,12 +8,18 @@ namespace NzbDrone.Core.Test.Framework
{
public interface ITestDatabase
{
void InsertMany<T>(IEnumerable<T> items) where T : ModelBase, new();
T Insert<T>(T item) where T : ModelBase, new();
List<T> All<T>() where T : ModelBase, new();
T Single<T>() where T : ModelBase, new();
void Update<T>(T childModel) where T : ModelBase, new();
void Delete<T>(T childModel) where T : ModelBase, new();
void InsertMany<T>(IEnumerable<T> items)
where T : ModelBase, new();
T Insert<T>(T item)
where T : ModelBase, new();
List<T> All<T>()
where T : ModelBase, new();
T Single<T>()
where T : ModelBase, new();
void Update<T>(T childModel)
where T : ModelBase, new();
void Delete<T>(T childModel)
where T : ModelBase, new();
IDirectDataMapper GetDirectDataMapper();
}
@@ -28,32 +34,38 @@ namespace NzbDrone.Core.Test.Framework
_dbConnection = dbConnection;
}
public void InsertMany<T>(IEnumerable<T> items) where T : ModelBase, new()
public void InsertMany<T>(IEnumerable<T> items)
where T : ModelBase, new()
{
new BasicRepository<T>(_dbConnection, _eventAggregator).InsertMany(items.ToList());
}
public T Insert<T>(T item) where T : ModelBase, new()
public T Insert<T>(T item)
where T : ModelBase, new()
{
return new BasicRepository<T>(_dbConnection, _eventAggregator).Insert(item);
}
public List<T> All<T>() where T : ModelBase, new()
public List<T> All<T>()
where T : ModelBase, new()
{
return new BasicRepository<T>(_dbConnection, _eventAggregator).All().ToList();
}
public T Single<T>() where T : ModelBase, new()
public T Single<T>()
where T : ModelBase, new()
{
return All<T>().SingleOrDefault();
}
public void Update<T>(T childModel) where T : ModelBase, new()
public void Update<T>(T childModel)
where T : ModelBase, new()
{
new BasicRepository<T>(_dbConnection, _eventAggregator).Update(childModel);
}
public void Delete<T>(T childModel) where T : ModelBase, new()
public void Delete<T>(T childModel)
where T : ModelBase, new()
{
new BasicRepository<T>(_dbConnection, _eventAggregator).Delete(childModel);
}