Exemple #1
0
        public async Task GetNothing_Entity()
        {
            var repository = new MemoryGenericRepository <Customer>();
            var existing   = await repository.Get();

            Assert.IsTrue(existing.Count() == 0);
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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));
        }