public async Task DeleteAsync_UsingNonexistentEntityKey_MustThrowException()
        {
            // Arrange
            var inMemoryDatabase =
                new DbContextOptionsBuilder <TodoDbContext>()
                .UseInMemoryDatabase($"db--{Guid.NewGuid():N}")
                .EnableDetailedErrors()
                .EnableSensitiveDataLogging();

            var mockLogger = new Mock <ILogger <TodoItemService> >();

            var owner = new Mock <IPrincipal>();

            owner.SetupGet(x => x.Identity).Returns(new GenericIdentity("test"));

            var deleteTodoItemInfo = new DeleteTodoItemInfo
            {
                Id    = long.MaxValue,
                Owner = owner.Object
            };

            var todoItemService = new TodoItemService(new TodoDbContext(inMemoryDatabase.Options), mockLogger.Object);

            // Act
            Func <Task> deleteAsyncCall = async() => await todoItemService.DeleteAsync(deleteTodoItemInfo);

            // Assert
            await deleteAsyncCall.Should().ThrowExactlyAsync <EntityNotFoundException>(
                "service cannot delete data using nonexistent entity key");
        }
        public async Task DeleteAsync_UsingNullAsDeleteTodoItemInfo_MustThrowException()
        {
            // Arrange
            var mockTodoDbContext = new DbContextMock <TodoDbContext>(DummyOptions);
            var mockLogger        = new Mock <ILogger <TodoItemService> >();
            var todoItemService   = new TodoItemService(mockTodoDbContext.Object, mockLogger.Object);
            DeleteTodoItemInfo deleteTodoItemInfo = null;

            // Act
            // ReSharper disable once ExpressionIsAlwaysNull
            Func <Task> deleteAsyncCall = async() => await todoItemService.DeleteAsync(deleteTodoItemInfo);

            // Assert
            await deleteAsyncCall
            .Should().ThrowExactlyAsync <ArgumentNullException>("service cannot delete data using a null item")
            .WithParameterName(nameof(deleteTodoItemInfo), "the item is null");
        }