public async Task GetList_User_ReturnSize(int size)
        {
            List <User> items = GetUsersDb(size);

            DbContextOptions <DemoContext> options = SqliteInMemory.CreateOptions <DemoContext>();

            using DemoContext context = new DemoContext(options);
            await ContextConfig.InitializeDatabaseContextSedd(context);

            await ContextConfig.AddDatabaseContext(context, items);

            IUserService userService = InjectUserService(context);

            List <DtoUserGet> result = await userService.GetList();

            result.Should().HaveCount(size);
        }
        public async Task Add_User_ReturnId_ReturnException(string userName, int yearsOld, string email, string password, bool active, int idRol)
        {
            List <User> items = GetUsersDb(10);

            DbContextOptions <DemoContext> options = SqliteInMemory.CreateOptions <DemoContext>();

            using DemoContext context = new DemoContext(options);
            await ContextConfig.InitializeDatabaseContextSedd(context);

            await ContextConfig.AddDatabaseContext(context, items);

            IUserService userService = InjectUserService(context);

            if (email == null)
            {
                await Assert.ThrowsAnyAsync <DbUpdateException>(() => userService.AddAsync(new DtoUserAdd
                {
                    UserName = userName,
                    YearsOld = yearsOld,
                    Email    = email,
                    Password = password,
                    Active   = active,
                    IdRol    = idRol
                }));
            }
            else
            {
                int?id = await userService.AddAsync(new DtoUserAdd
                {
                    UserName = userName,
                    YearsOld = yearsOld,
                    Email    = email,
                    Password = password,
                    Active   = active,
                    IdRol    = idRol
                });

                id.Should().NotBeNull();
            }
        }
        public async Task Delete_User_Return(int id)
        {
            List <User> items = GetUsersDb(2);

            DbContextOptions <DemoContext> options = SqliteInMemory.CreateOptions <DemoContext>();

            using DemoContext context = new DemoContext(options);
            await ContextConfig.InitializeDatabaseContextSedd(context);

            await ContextConfig.AddDatabaseContext(context, items);

            IUserService userService = InjectUserService(context);

            int?result = await userService.Delete(id);

            if (id == 0)
            {
                result.Should().BeNull();
            }
            else
            {
                result.Should().NotBeNull();
            }
        }
        public async Task Get_User_RetunIdItem_ReturnBeNull(int id)
        {
            List <User> items = GetUsersDb(10);

            DbContextOptions <DemoContext> options = SqliteInMemory.CreateOptions <DemoContext>();

            using DemoContext context = new DemoContext(options);
            await ContextConfig.InitializeDatabaseContextSedd(context);

            await ContextConfig.AddDatabaseContext(context, items);

            IUserService userService = InjectUserService(context);

            DtoUserGet result = await userService.Get(id);

            if (id == 0)
            {
                result.ShouldBeNull();
            }
            else
            {
                result.Id.Should().Be(id);
            }
        }
        public async Task Update_User_ReturnPassword_ReturnNull(int id, string password, string email)
        {
            List <User> items = GetUsersDb(2);

            DbContextOptions <DemoContext> options = SqliteInMemory.CreateOptions <DemoContext>();

            using DemoContext context = new DemoContext(options);
            await ContextConfig.InitializeDatabaseContextSedd(context);

            await ContextConfig.AddDatabaseContext(context, items);

            IUserService userService = InjectUserService(context);

            int?result = await userService.UpdateAsync(new DtoUserUpdate { Id = id, Password = password, Email = email });

            if (id == 0)
            {
                result.Should().BeNull();
            }
            else
            {
                context.User.Find(id).Password.Should().Be(password);
            }
        }