Send To Device Support (#1557)
* Tweaked the logging output * Started implementing some basic idea for devices * Updated Email Service with new API routes * Implemented basic DB structure and some APIs to prep for the UI and flows. * Added an abstract class to make Unit testing easier. * Removed dependency we don't need * Updated the UI to be able to show devices and add new devices. Email field will update the platform if the user hasn't interacted with it already. * Added ability to delete a device as well * Basic ability to send files to devices works * Refactored Action code to pass ActionItem back and allow for dynamic children based on an Observable (api). Hooked in ability to send a chapter to a device. There is no logic in the FE to validate type. * Fixed a broken unit test * Implemented the ability to edit a device * Code cleanup * Fixed a bad success message * Fixed broken unit test from updating mock layer
This commit is contained in:
parent
ab0f13ef74
commit
9d7476a367
79 changed files with 3026 additions and 157 deletions
79
API.Tests/Services/DeviceServiceTests.cs
Normal file
79
API.Tests/Services/DeviceServiceTests.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
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 void ResetDB()
|
||||
{
|
||||
_context.Users.RemoveRange(_context.Users.ToList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
[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);
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue