mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-22 15:00:34 -04:00
* Fixed inputs not showing inline validation due to a missing class * Fixed some checks * Increased the button size on manga reader (develop) * Migrated a type cast to a pure pipe * Sped up the check for if SendTo should render on the menu * Don't allow user to bookmark in bookmark mode * Fixed a bug where Scan Series would skip over Specials due to how new scan loop works. * Fixed scroll to top button persisting when navigating between pages * Edit Series modal now doesn't have a lock field for Series, which can't be locked as it is inheritently locked. Added some validation to ensure Name and SortName are required. * Fixed up some spacing * Fixed actionable menu not opening submenu on mobile * Cleaned up the layout of cover image on series detail * Show all volume or chapters (if only one volume) for cover selection on series * Don't open submenu to right if there is no space * Fixed up cover image not allowing custom saves of existing series/chapter/volume images. Fixed up logging so console output matches log file. * Implemented the ability to turn off css transitions in the UI. * Updated a note internally * Code smells * Added InstallId when pinging the email service to allow throughput tracking
81 lines
1.9 KiB
C#
81 lines
1.9 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using API.DTOs.Device;
|
|
using API.Entities;
|
|
using API.Entities.Enums.Device;
|
|
using API.Services;
|
|
using API.Services.Tasks;
|
|
using Microsoft.Extensions.Logging;
|
|
using NSubstitute;
|
|
using Xunit;
|
|
|
|
namespace API.Tests.Services;
|
|
|
|
public class DeviceServiceTests : BasicTest
|
|
{
|
|
private readonly ILogger<DeviceService> _logger = Substitute.For<ILogger<DeviceService>>();
|
|
private readonly IDeviceService _deviceService;
|
|
|
|
public DeviceServiceTests() : base()
|
|
{
|
|
_deviceService = new DeviceService(_unitOfWork, _logger, Substitute.For<IEmailService>());
|
|
}
|
|
|
|
protected new Task ResetDb()
|
|
{
|
|
_context.Users.RemoveRange(_context.Users.ToList());
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
public async Task CreateDevice_Succeeds()
|
|
{
|
|
|
|
var user = new AppUser()
|
|
{
|
|
UserName = "majora2007",
|
|
Devices = new List<Device>()
|
|
};
|
|
|
|
_context.Users.Add(user);
|
|
await _unitOfWork.CommitAsync();
|
|
|
|
var device = await _deviceService.Create(new CreateDeviceDto()
|
|
{
|
|
EmailAddress = "fake@kindle.com",
|
|
Name = "Test Kindle",
|
|
Platform = DevicePlatform.Kindle
|
|
}, user);
|
|
|
|
Assert.NotNull(device);
|
|
|
|
}
|
|
|
|
[Fact]
|
|
public async Task CreateDevice_ThrowsErrorWhenEmailDoesntMatchRules()
|
|
{
|
|
|
|
var user = new AppUser()
|
|
{
|
|
UserName = "majora2007",
|
|
Devices = new List<Device>()
|
|
};
|
|
|
|
_context.Users.Add(user);
|
|
await _unitOfWork.CommitAsync();
|
|
|
|
var device = await _deviceService.Create(new CreateDeviceDto()
|
|
{
|
|
EmailAddress = "fake@gmail.com",
|
|
Name = "Test Kindle",
|
|
Platform = DevicePlatform.Kindle
|
|
}, user);
|
|
|
|
Assert.NotNull(device);
|
|
|
|
}
|
|
}
|