Removed todos and added User endpoint combined with register. Id changed to guid
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Hutopy.Application.Common.Behaviours;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Application.TodoItems.Commands.CreateTodoItem;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@@ -9,37 +8,13 @@ namespace Hutopy.Application.UnitTests.Common.Behaviours;
|
||||
|
||||
public class RequestLoggerTests
|
||||
{
|
||||
private Mock<ILogger<CreateTodoItemCommand>> _logger = null!;
|
||||
private Mock<IUser> _user = null!;
|
||||
private Mock<IIdentityService> _identityService = null!;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_logger = new Mock<ILogger<CreateTodoItemCommand>>();
|
||||
_user = new Mock<IUser>();
|
||||
_identityService = new Mock<IIdentityService>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ShouldCallGetUserNameAsyncOnceIfAuthenticated()
|
||||
{
|
||||
_user.Setup(x => x.Id).Returns(Guid.NewGuid().ToString());
|
||||
|
||||
var requestLogger = new LoggingBehaviour<CreateTodoItemCommand>(_logger.Object, _user.Object, _identityService.Object);
|
||||
|
||||
await requestLogger.Process(new CreateTodoItemCommand { ListId = 1, Title = "title" }, new CancellationToken());
|
||||
|
||||
_identityService.Verify(i => i.GetUserNameAsync(It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ShouldNotCallGetUserNameAsyncOnceIfUnauthenticated()
|
||||
{
|
||||
var requestLogger = new LoggingBehaviour<CreateTodoItemCommand>(_logger.Object, _user.Object, _identityService.Object);
|
||||
|
||||
await requestLogger.Process(new CreateTodoItemCommand { ListId = 1, Title = "title" }, new CancellationToken());
|
||||
|
||||
_identityService.Verify(i => i.GetUserNameAsync(It.IsAny<string>()), Times.Never);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ using System.Runtime.CompilerServices;
|
||||
using AutoMapper;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Application.Common.Models;
|
||||
using Hutopy.Application.TodoItems.Queries.GetTodoItemsWithPagination;
|
||||
using Hutopy.Application.TodoLists.Queries.GetTodos;
|
||||
using Hutopy.Domain.Entities;
|
||||
using NUnit.Framework;
|
||||
|
||||
@@ -17,7 +15,7 @@ public class MappingTests
|
||||
|
||||
public MappingTests()
|
||||
{
|
||||
_configuration = new MapperConfiguration(config =>
|
||||
_configuration = new MapperConfiguration(config =>
|
||||
config.AddMaps(Assembly.GetAssembly(typeof(IApplicationDbContext))));
|
||||
|
||||
_mapper = _configuration.CreateMapper();
|
||||
@@ -29,19 +27,6 @@ public class MappingTests
|
||||
_configuration.AssertConfigurationIsValid();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(typeof(TodoList), typeof(TodoListDto))]
|
||||
[TestCase(typeof(TodoItem), typeof(TodoItemDto))]
|
||||
[TestCase(typeof(TodoList), typeof(LookupDto))]
|
||||
[TestCase(typeof(TodoItem), typeof(LookupDto))]
|
||||
[TestCase(typeof(TodoItem), typeof(TodoItemBriefDto))]
|
||||
public void ShouldSupportMappingFromSourceToDestination(Type source, Type destination)
|
||||
{
|
||||
var instance = GetInstanceOf(source);
|
||||
|
||||
_mapper.Map(instance, source, destination);
|
||||
}
|
||||
|
||||
private object GetInstanceOf(Type type)
|
||||
{
|
||||
if (type.GetConstructor(Type.EmptyTypes) != null)
|
||||
|
||||
Reference in New Issue
Block a user