public async Task GetNothing_Entity() { var repository = new MemoryGenericRepository <Customer>(); var existing = await repository.Get(); Assert.IsTrue(existing.Count() == 0); }
public async Task Insert_Entity() { var repository = new MemoryGenericRepository <Customer>(); var newEntity = await repository.Insert(new Customer() { Name = _entityDefaultName }); Assert.IsTrue(newEntity.ID > 0); }
public async Task GetByName_Entity() { var repository = new MemoryGenericRepository <Customer>(); var newEntity = await repository.Insert(new Customer() { Name = _entityDefaultName }); var existing = await repository.Get(x => x.Name == _entityDefaultName); Assert.IsNotNull(existing); }
public async Task DeleteByID_Entity() { var repository = new MemoryGenericRepository <Customer>(); var newEntity = await repository.Insert(new Customer() { Name = _entityDefaultName }); await repository.Delete(newEntity.ID); var existing = await repository.Get(newEntity.ID); Assert.IsNull(existing); }
public async Task Update_Entity() { var repository = new MemoryGenericRepository <Customer>(); var newEntity = await repository.Insert(new Customer() { Name = _entityDefaultName }); var existing = await repository.Get(newEntity.ID); existing.Name = _entityNewName; await repository.Update(existing); var updated = await repository.Get(newEntity.ID); Assert.IsNotNull(updated); }
public async Task GetOrdered_Entity() { var repository = new MemoryGenericRepository <Customer>(); var newEntity = await repository.Insert(new Customer() { Name = _entityNewName }); var defaultEntity = await repository.Insert(new Customer() { Name = _entityDefaultName }); var ordered = await repository.Get(orderBy : (x => x.OrderBy(c => c.Name))); Assert.IsNotNull(ordered.First(c => c.Name == _entityDefaultName)); }