예제 #1
0
        public async void Insert_ValidateOk()
        {
            using (var context = new AuthDbContext(CreateNewContextOptions()))
            {
                TRepository repo   = _baseRepository.GetNewRepository(context);
                TEntity     entity = _baseRepository.GetNewValidEntity();

                await repo.InsertAsync(entity);

                await context.SaveChangesAsync();

                Assert.Equal(1, context.Set <TEntity>().Count());
                _baseRepository.AssertAllProperties(entity, context.Set <TEntity>().First());
            }
        }
예제 #2
0
        public async void SelectById_ObtainOne()
        {
            using (var context = new AuthDbContext(CreateNewContextOptions()))
            {
                TRepository repo   = _baseRepository.GetNewRepository(context);
                TEntity     entity = _baseRepository.GetNewValidEntity();
                await context.Set <TEntity>().AddAsync(entity);

                await context.SaveChangesAsync();

                var entityById = await repo.SelectByIdAsync(entity.GetIds);

                Assert.NotNull(entityById);
                _baseRepository.AssertAllProperties(entity, context.Set <TEntity>().First());
            }
        }
예제 #3
0
        public async void Delete_ValidateOk()
        {
            using (var context = new AuthDbContext(CreateNewContextOptions()))
            {
                TRepository repo   = _baseRepository.GetNewRepository(context);
                TEntity     entity = _baseRepository.GetNewValidEntity();
                await context.Set <TEntity>().AddAsync(entity);

                await context.SaveChangesAsync();

                repo.Delete(entity);
                await context.SaveChangesAsync();

                Assert.Empty(context.Systems);
            }
        }
예제 #4
0
        public async void Update_ValidateOk()
        {
            using (var context = new AuthDbContext(CreateNewContextOptions()))
            {
                TRepository repo   = _baseRepository.GetNewRepository(context);
                TEntity     entity = _baseRepository.GetNewValidEntity();
                await context.Set <TEntity>().AddAsync(entity);

                await context.SaveChangesAsync();

                _baseRepository.ChangeNotIdProperties(ref entity);

                repo.Update(entity);
                await context.SaveChangesAsync();

                _baseRepository.AssertAllProperties(entity, context.Set <TEntity>().First());
            }
        }