Cleanup.
This commit is contained in:
parent
d0242f235c
commit
d6020594ef
10 changed files with 65 additions and 64 deletions
|
|
@ -20,11 +20,11 @@ public class WatchFolderCheckerTests : IDisposable
|
|||
|
||||
public WatchFolderCheckerTests()
|
||||
{
|
||||
_loggerMock = new Mock<ILogger<WatchFolderChecker>>();
|
||||
_serviceProviderMock = new Mock<IServiceProvider>();
|
||||
_serviceScopeMock = new Mock<IServiceScope>();
|
||||
_scopeServiceProviderMock = new Mock<IServiceProvider>();
|
||||
_torrentsServiceMock = new Mock<Torrents>(null!, null!, null!, null!, null!, null!, null!, null!, null!, null!, null!);
|
||||
_loggerMock = new();
|
||||
_serviceProviderMock = new();
|
||||
_serviceScopeMock = new();
|
||||
_scopeServiceProviderMock = new();
|
||||
_torrentsServiceMock = new(null!, null!, null!, null!, null!, null!, null!, null!, null!, null!, null!);
|
||||
|
||||
_serviceProviderMock
|
||||
.Setup(x => x.GetService(typeof(IServiceScopeFactory)))
|
||||
|
|
@ -65,12 +65,12 @@ public class WatchFolderCheckerTests : IDisposable
|
|||
{
|
||||
var settings = new Data.Models.Internal.DbSettings
|
||||
{
|
||||
Watch = new Data.Models.Internal.DbSettingsWatch
|
||||
Watch = new()
|
||||
{
|
||||
Interval = 0,
|
||||
Default = new Data.Models.Internal.DbSettingsDefaultsWithCategory()
|
||||
Default = new()
|
||||
},
|
||||
DownloadClient = new Data.Models.Internal.DbSettingsDownloadClient()
|
||||
DownloadClient = new()
|
||||
};
|
||||
|
||||
var property = typeof(SettingData).GetProperty("Get", BindingFlags.Public | BindingFlags.Static);
|
||||
|
|
|
|||
|
|
@ -15,21 +15,21 @@ public class NzbTorrentsTest
|
|||
|
||||
public NzbTorrentsTest()
|
||||
{
|
||||
_mocks = new Mocks();
|
||||
_fileSystem = new MockFileSystem();
|
||||
_torrents = new TorrentsService(
|
||||
_mocks.TorrentsLoggerMock.Object,
|
||||
_mocks.TorrentDataMock.Object,
|
||||
_mocks.DownloadsMock.Object,
|
||||
_mocks.ProcessFactoryMock.Object,
|
||||
_fileSystem,
|
||||
_mocks.EnricherMock.Object,
|
||||
null!,
|
||||
null!,
|
||||
null!,
|
||||
null!,
|
||||
null!
|
||||
);
|
||||
_mocks = new();
|
||||
_fileSystem = new();
|
||||
_torrents = new(
|
||||
_mocks.TorrentsLoggerMock.Object,
|
||||
_mocks.TorrentDataMock.Object,
|
||||
_mocks.DownloadsMock.Object,
|
||||
_mocks.ProcessFactoryMock.Object,
|
||||
_fileSystem,
|
||||
_mocks.EnricherMock.Object,
|
||||
null!,
|
||||
null!,
|
||||
null!,
|
||||
null!,
|
||||
null!
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ public class QBittorrentTest
|
|||
|
||||
public QBittorrentTest()
|
||||
{
|
||||
_loggerMock = new Mock<ILogger<QBittorrent>>();
|
||||
_torrentsMock = new Mock<Torrents>(null!, null!, null!, null!, null!, null!, null!, null!, null!, null!, null!);
|
||||
_authenticationMock = new Mock<Authentication>(null!, null!, null!);
|
||||
_loggerMock = new();
|
||||
_torrentsMock = new(null!, null!, null!, null!, null!, null!, null!, null!, null!, null!, null!);
|
||||
_authenticationMock = new(null!, null!, null!);
|
||||
|
||||
_qBittorrent = new QBittorrent(_loggerMock.Object, null!, _authenticationMock.Object, _torrentsMock.Object, null!);
|
||||
_qBittorrent = new(_loggerMock.Object, null!, _authenticationMock.Object, _torrentsMock.Object, null!);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class SabnzbdTest
|
|||
|
||||
public SabnzbdTest()
|
||||
{
|
||||
_torrentsMock = new Mock<Torrents>(null!, null!, null!, null!, null!, null!, null!, null!, null!, null!, null!);
|
||||
_torrentsMock = new(null!, null!, null!, null!, null!, null!, null!, null!, null!, null!, null!);
|
||||
_torrentsMock.Setup(t => t.Get()).ReturnsAsync(new List<Torrent>());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ public class TorBoxDebridClientTest
|
|||
|
||||
public TorBoxDebridClientTest()
|
||||
{
|
||||
_loggerMock = new Mock<ILogger<TorBoxDebridClient>>();
|
||||
_httpClientFactoryMock = new Mock<IHttpClientFactory>();
|
||||
_fileFilterMock = new Mock<IDownloadableFileFilter>();
|
||||
_loggerMock = new();
|
||||
_httpClientFactoryMock = new();
|
||||
_fileFilterMock = new();
|
||||
|
||||
var httpClient = new HttpClient();
|
||||
_httpClientFactoryMock.Setup(m => m.CreateClient(It.IsAny<String>())).Returns(httpClient);
|
||||
|
|
@ -71,11 +71,11 @@ public class TorBoxDebridClientTest
|
|||
var hash = "test-hash";
|
||||
var availability = new Response<List<AvailableTorrent?>>
|
||||
{
|
||||
Data = new List<AvailableTorrent?>
|
||||
Data = new()
|
||||
{
|
||||
new()
|
||||
{
|
||||
Files = new List<AvailableTorrentFile>
|
||||
Files = new()
|
||||
{
|
||||
new() { Name = "file1.mkv", Size = 100 },
|
||||
new() { Name = "file2.txt", Size = 10 }
|
||||
|
|
@ -103,14 +103,14 @@ public class TorBoxDebridClientTest
|
|||
{
|
||||
// Arrange
|
||||
var hash = "test-hash";
|
||||
var torrentAvailability = new Response<List<AvailableTorrent?>> { Data = new List<AvailableTorrent?>() };
|
||||
var torrentAvailability = new Response<List<AvailableTorrent?>> { Data = new() };
|
||||
var usenetAvailability = new Response<List<AvailableUsenet?>>
|
||||
{
|
||||
Data = new List<AvailableUsenet?>
|
||||
Data = new()
|
||||
{
|
||||
new()
|
||||
{
|
||||
Files = new List<AvailableUsenetFile>
|
||||
Files = new()
|
||||
{
|
||||
new() { Name = "file1.nzb", Size = 200 }
|
||||
}
|
||||
|
|
@ -136,8 +136,8 @@ public class TorBoxDebridClientTest
|
|||
{
|
||||
// Arrange
|
||||
var hash = "test-hash";
|
||||
var torrentAvailability = new Response<List<AvailableTorrent?>> { Data = new List<AvailableTorrent?>() };
|
||||
var usenetAvailability = new Response<List<AvailableUsenet?>> { Data = new List<AvailableUsenet?>() };
|
||||
var torrentAvailability = new Response<List<AvailableTorrent?>> { Data = new() };
|
||||
var usenetAvailability = new Response<List<AvailableUsenet?>> { Data = new() };
|
||||
|
||||
var clientMock = new Mock<TorBoxDebridClient>(_loggerMock.Object, _httpClientFactoryMock.Object, _fileFilterMock.Object);
|
||||
clientMock.Protected().Setup<Task<Response<List<AvailableTorrent?>>>>("GetTorrentAvailability", hash).ReturnsAsync(torrentAvailability);
|
||||
|
|
@ -270,7 +270,8 @@ public class TorBoxDebridClientTest
|
|||
clientMock.Protected().Setup<ITorBoxNetClient>("GetClient").Returns(torBoxClientMock.Object);
|
||||
|
||||
usenetApiMock.Setup(m => m.AddFileAsync(bytes, -1, name, null, It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new Response<UsenetAddResult> { Data = new UsenetAddResult { Hash = "new-hash" } });
|
||||
.ReturnsAsync(new Response<UsenetAddResult> { Data = new()
|
||||
{ Hash = "new-hash" } });
|
||||
|
||||
// Act
|
||||
var result = await clientMock.Object.AddNzbFile(bytes, name);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class CredentialRedactorEnricher : ILogEventEnricher
|
|||
if (property.Value is ScalarValue scalarValue && scalarValue.Value is String stringValue && stringValue.Contains(sensitiveValue))
|
||||
{
|
||||
var newValue = stringValue.Replace(sensitiveValue, "*****");
|
||||
propertiesToUpdate.Add(new LogEventProperty(property.Key, new ScalarValue(newValue)));
|
||||
propertiesToUpdate.Add(new(property.Key, new ScalarValue(newValue)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ public class Sabnzbd(ILogger<Sabnzbd> logger, Torrents torrents, AppSettings app
|
|||
|
||||
var config = new SabnzbdConfig
|
||||
{
|
||||
Misc = new SabnzbdMisc
|
||||
Misc = new()
|
||||
{
|
||||
CompleteDir = savePath,
|
||||
DownloadDir = savePath,
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ public class SabnzbdControllerTest
|
|||
|
||||
var torrentsMock = new Mock<Torrents>(null!, null!, null!, null!, null!, null!, null!, null!, null!, null!, null!);
|
||||
var sabnzbdLoggerMock = new Mock<ILogger<Sabnzbd>>();
|
||||
_sabnzbdMock = new Mock<Sabnzbd>(sabnzbdLoggerMock.Object, torrentsMock.Object, null!);
|
||||
_sabnzbdMock = new(sabnzbdLoggerMock.Object, torrentsMock.Object, null!);
|
||||
var loggerMock = new Mock<ILogger<SabnzbdController>>();
|
||||
_authenticationMock = new Mock<Authentication>(null!, null!, null!);
|
||||
_authenticationMock = new(null!, null!, null!);
|
||||
|
||||
_controller = new SabnzbdController(loggerMock.Object, _sabnzbdMock.Object);
|
||||
_controller = new(loggerMock.Object, _sabnzbdMock.Object);
|
||||
|
||||
var httpContext = new DefaultHttpContext();
|
||||
_controller.ControllerContext = new ControllerContext
|
||||
_controller.ControllerContext = new()
|
||||
{
|
||||
HttpContext = httpContext
|
||||
};
|
||||
|
|
@ -75,7 +75,7 @@ public class SabnzbdControllerTest
|
|||
// Arrange
|
||||
Data.Data.SettingData.Get.General.AuthenticationType = Data.Enums.AuthenticationType.UserNamePassword;
|
||||
var httpContext = new DefaultHttpContext();
|
||||
httpContext.Request.QueryString = new QueryString("?ma_username=user&ma_password=pass");
|
||||
httpContext.Request.QueryString = new("?ma_username=user&ma_password=pass");
|
||||
_controller.ControllerContext.HttpContext = httpContext;
|
||||
|
||||
_authenticationMock.Setup(a => a.Login("user", "pass")).ReturnsAsync(Microsoft.AspNetCore.Identity.SignInResult.Success);
|
||||
|
|
@ -140,7 +140,8 @@ public class SabnzbdControllerTest
|
|||
public void GetConfig_ReturnsOk()
|
||||
{
|
||||
// Arrange
|
||||
var config = new SabnzbdConfig { Misc = new SabnzbdMisc { Port = "6500" } };
|
||||
var config = new SabnzbdConfig { Misc = new()
|
||||
{ Port = "6500" } };
|
||||
_sabnzbdMock.Setup(s => s.GetConfig()).Returns(config);
|
||||
|
||||
// Act
|
||||
|
|
@ -199,7 +200,7 @@ public class SabnzbdControllerTest
|
|||
// Arrange
|
||||
var httpContext = new DefaultHttpContext();
|
||||
httpContext.Request.ContentType = "application/x-www-form-urlencoded";
|
||||
httpContext.Request.Form = new FormCollection(new Dictionary<String, Microsoft.Extensions.Primitives.StringValues>
|
||||
httpContext.Request.Form = new FormCollection(new()
|
||||
{
|
||||
{ "mode", "unknown_form" }
|
||||
});
|
||||
|
|
@ -218,7 +219,7 @@ public class SabnzbdControllerTest
|
|||
// Arrange
|
||||
var httpContext = new DefaultHttpContext();
|
||||
httpContext.Request.Method = "POST";
|
||||
httpContext.Request.QueryString = new QueryString("?cat=radarr&priority=-100");
|
||||
httpContext.Request.QueryString = new("?cat=radarr&priority=-100");
|
||||
|
||||
// Mocking multipart form data
|
||||
var fileMock = new Mock<IFormFile>();
|
||||
|
|
@ -237,7 +238,7 @@ public class SabnzbdControllerTest
|
|||
.Returns(Task.CompletedTask);
|
||||
|
||||
httpContext.Request.ContentType = "multipart/form-data; boundary=something";
|
||||
httpContext.Request.Form = new FormCollection(new Dictionary<String, Microsoft.Extensions.Primitives.StringValues>(), new FormFileCollection { fileMock.Object });
|
||||
httpContext.Request.Form = new FormCollection(new(), new FormFileCollection { fileMock.Object });
|
||||
|
||||
_controller.ControllerContext.HttpContext = httpContext;
|
||||
_sabnzbdMock.Setup(s => s.AddFile(It.IsAny<Byte[]>(), fileName, "radarr", -100)).ReturnsAsync("nzo_id_123");
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ public class SabnzbdHandlerTest
|
|||
|
||||
public SabnzbdHandlerTest()
|
||||
{
|
||||
_authenticationMock = new Mock<Authentication>(null!, null!, null!);
|
||||
_httpContextAccessorMock = new Mock<IHttpContextAccessor>();
|
||||
_handler = new SabnzbdHandler(_authenticationMock.Object, _httpContextAccessorMock.Object);
|
||||
_authenticationMock = new(null!, null!, null!);
|
||||
_httpContextAccessorMock = new();
|
||||
_handler = new(_authenticationMock.Object, _httpContextAccessorMock.Object);
|
||||
Data.Data.SettingData.Get.General.AuthenticationType = AuthenticationType.UserNamePassword;
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ public class SabnzbdHandlerTest
|
|||
// Arrange
|
||||
Settings.Get.General.AuthenticationType = AuthenticationType.UserNamePassword;
|
||||
var httpContext = new DefaultHttpContext();
|
||||
httpContext.Request.QueryString = new QueryString("?ma_username=user&ma_password=pass");
|
||||
httpContext.Request.QueryString = new("?ma_username=user&ma_password=pass");
|
||||
_httpContextAccessorMock.Setup(a => a.HttpContext).Returns(httpContext);
|
||||
|
||||
var context = CreateContext(httpContext);
|
||||
|
|
@ -79,7 +79,7 @@ public class SabnzbdHandlerTest
|
|||
// Arrange
|
||||
Settings.Get.General.AuthenticationType = AuthenticationType.UserNamePassword;
|
||||
var httpContext = new DefaultHttpContext();
|
||||
httpContext.Request.QueryString = new QueryString("?ma_username=user&ma_password=wrong");
|
||||
httpContext.Request.QueryString = new("?ma_username=user&ma_password=wrong");
|
||||
_httpContextAccessorMock.Setup(a => a.HttpContext).Returns(httpContext);
|
||||
|
||||
var context = CreateContext(httpContext);
|
||||
|
|
@ -113,6 +113,6 @@ public class SabnzbdHandlerTest
|
|||
{
|
||||
var requirement = new SabnzbdRequirement();
|
||||
var user = httpContext?.User ?? new System.Security.Claims.ClaimsPrincipal();
|
||||
return new AuthorizationHandlerContext([requirement], user, null);
|
||||
return new([requirement], user, null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Http;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using RdtClient.Data.Models.Data;
|
||||
using RdtClient.Service.Services;
|
||||
using RdtClient.Web.Controllers;
|
||||
|
||||
|
|
@ -16,9 +15,9 @@ public class TorrentsControllerNzbTest
|
|||
|
||||
public TorrentsControllerNzbTest()
|
||||
{
|
||||
_torrentsMock = new Mock<Torrents>(null!, null!, null!, null!, null!, null!, null!, null!, null!, null!, null!);
|
||||
_loggerMock = new Mock<ILogger<TorrentsController>>();
|
||||
_controller = new TorrentsController(_loggerMock.Object, _torrentsMock.Object, null!);
|
||||
_torrentsMock = new(null!, null!, null!, null!, null!, null!, null!, null!, null!, null!, null!);
|
||||
_loggerMock = new();
|
||||
_controller = new(_loggerMock.Object, _torrentsMock.Object, null!);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -28,7 +27,7 @@ public class TorrentsControllerNzbTest
|
|||
var request = new TorrentControllerUploadNzbLinkRequest
|
||||
{
|
||||
NzbLink = "http://example.com/test.nzb",
|
||||
Torrent = new Torrent()
|
||||
Torrent = new()
|
||||
};
|
||||
|
||||
// Act
|
||||
|
|
@ -56,7 +55,7 @@ public class TorrentsControllerNzbTest
|
|||
var request = new TorrentControllerUploadNzbLinkRequest
|
||||
{
|
||||
NzbLink = "",
|
||||
Torrent = new Torrent()
|
||||
Torrent = new()
|
||||
};
|
||||
|
||||
// Act
|
||||
|
|
@ -86,7 +85,7 @@ public class TorrentsControllerNzbTest
|
|||
|
||||
var formData = new TorrentControllerUploadFileRequest
|
||||
{
|
||||
Torrent = new Torrent()
|
||||
Torrent = new()
|
||||
};
|
||||
|
||||
// Act
|
||||
|
|
@ -102,7 +101,7 @@ public class TorrentsControllerNzbTest
|
|||
public async Task UploadNzbFile_NoFile_ReturnsBadRequest()
|
||||
{
|
||||
// Act
|
||||
var result = await _controller.UploadNzbFile(null, new TorrentControllerUploadFileRequest());
|
||||
var result = await _controller.UploadNzbFile(null, new());
|
||||
|
||||
// Assert
|
||||
var badRequest = Assert.IsType<BadRequestObjectResult>(result);
|
||||
|
|
|
|||
Loading…
Reference in a new issue