Пример #1
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());
            }
        }
Пример #2
0
        public async void Insert_Existent_Id_ThrowException()
        {
            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);

                Func <Task> insertFunction = async() =>
                {
                    await repo.InsertAsync(entity);

                    await context.SaveChangesAsync();
                };

                await Assert.ThrowsAsync <ArgumentException>(insertFunction);
            }
        }