public async Task DeleteSupplier()
        {
            await using var context = DatabaseHelper.CreateInMemoryDatabaseContext(nameof(DeleteSupplier));
            var supplierId1Task = context.AddAsync(ValidModelCreator.Supplier());
            var supplierId2Task = context.AddAsync(ValidModelCreator.Supplier());
            var supplierId3Task = context.AddAsync(ValidModelCreator.Supplier());

            var supplier1Id        = (await supplierId1Task).Entity.Id;
            var supplier2Id        = (await supplierId2Task).Entity.Id;
            var supplier3Id        = (await supplierId3Task).Entity.Id;
            var deleteSupplier2Cmd = new DeleteSupplierCommand
            {
                Id = supplier2Id,
            };
            var deleteHandler = new DeleteSupplierCommandHandler(context);
            var deleteResult1 = await deleteHandler.Handle(deleteSupplier2Cmd, CancellationToken.None);

            Assert.True(deleteResult1.Success);
            var querySupplier2 = new GetSupplierByIdQuery {
                Id = supplier2Id
            };
            var queryOneHandler   = new GetSupplierByIdQueryHandler(context);
            var querySupplier2Res = await queryOneHandler.Handle(querySupplier2, CancellationToken.None);

            Assert.False(querySupplier2Res.Success);

            var deleteResult2 = await deleteHandler.Handle(deleteSupplier2Cmd, CancellationToken.None);

            Assert.False(deleteResult2.Success);

            var querySupplier1 = new GetSupplierByIdQuery {
                Id = supplier1Id
            };
            var query1Result = await queryOneHandler.Handle(querySupplier1, CancellationToken.None);

            Assert.True(query1Result.Success);
            var querySupplier3 = new GetSupplierByIdQuery {
                Id = supplier3Id
            };
            var query3Result = await queryOneHandler.Handle(querySupplier3, CancellationToken.None);

            Assert.True(query3Result.Success);
        }
        public async Task TestCreateSuccess()
        {
            var cmd = new CreateSupplierCommand
            {
                Email = "*****@*****.**",
                Name  = "Pascal",
                Phone = "+41 79 456 45 45"
            };

            await using var context = DatabaseHelper.CreateInMemoryDatabaseContext(nameof(TestCreateSuccess));
            var cmdHandler  = new CreateSupplierCommandHandler(context);
            var cmdResponse = await cmdHandler.Handle(cmd, CancellationToken.None);

            var supplierId = cmdResponse.Data;

            Assert.True(cmdResponse.Success);
            var queryOneHandler = new GetSupplierByIdQueryHandler(context);
            var queryOne        = new GetSupplierByIdQuery {
                Id = supplierId
            };
            var queryOneResponse = await queryOneHandler.Handle(queryOne, CancellationToken.None);

            Assert.True(queryOneResponse.Success);
            Assert.Equal(supplierId, queryOneResponse.Data.Id);
            Assert.Equal(cmd.Email, queryOneResponse.Data.Email);
            Assert.Equal(cmd.Name, queryOneResponse.Data.Name);
            Assert.Equal(cmd.Phone, queryOneResponse.Data.Phone);

            var queryAll         = new GetAllSuppliersQuery();
            var queryAllHandler  = new GetAllSuppliersQueryHandler(context);
            var queryAllResponse = await queryAllHandler.Handle(queryAll, CancellationToken.None);

            Assert.True(queryAllResponse.Success);
            Assert.NotEmpty(queryAllResponse.Data);
            Assert.Contains(queryAllResponse.Data, s => s.Id.Equals(supplierId));
        }
        public async Task TestUpdateSupplierSuccess()
        {
            await using var context = DatabaseHelper.CreateInMemoryDatabaseContext(nameof(TestUpdateSupplierSuccess));

            var addedSupplier = await context.Suppliers.AddAsync(ValidModelCreator.Supplier());

            var supplier1Id = addedSupplier.Entity.Id;

            var updateCmd1 = new UpdateSupplierCommand
            {
                Id    = supplier1Id,
                Name  = "something",
                Email = "*****@*****.**",
                Phone = null,
            };

            var updateHandler   = new UpdateSupplierCommandHandler(context);
            var queryOneHandler = new GetSupplierByIdQueryHandler(context);
            var response1       = await updateHandler.Handle(updateCmd1, CancellationToken.None);

            Assert.True(response1.Success);
            var updatedSupplier =
                (await queryOneHandler.Handle(new GetSupplierByIdQuery {
                Id = updateCmd1.Id
            }, CancellationToken.None))
                .Data;

            Assert.Equal(updateCmd1.Name, updatedSupplier.Name);
            Assert.Equal(updateCmd1.Email, updatedSupplier.Email);
            Assert.Equal(updateCmd1.Phone, updatedSupplier.Phone);
            var updateCmd2 = new UpdateSupplierCommand
            {
                Id    = supplier1Id,
                Name  = "something new",
                Email = "*****@*****.**",
                Phone = "+41 79 456 45 45",
            };

            var response2 = await updateHandler.Handle(updateCmd2, CancellationToken.None);

            Assert.True(response2.Success);
            var updatedAgain =
                (await queryOneHandler.Handle(new GetSupplierByIdQuery {
                Id = updateCmd1.Id
            }, CancellationToken.None))
                .Data;

            Assert.Equal(updateCmd2.Name, updatedAgain.Name);
            Assert.Equal(updateCmd2.Email, updatedAgain.Email);
            Assert.Equal(updateCmd2.Phone, updatedAgain.Phone);

            var updateNonExistingSupplierCommand = new UpdateSupplierCommand
            {
                Id    = supplier1Id + 1,
                Name  = "something",
                Email = "*****@*****.**",
                Phone = "+41 79 456 45 45",
            };
            var response3 = await updateHandler.Handle(updateNonExistingSupplierCommand, CancellationToken.None);

            Assert.False(response3.Success);
        }