Пример #1
0
        public void InsertsEntity()
        {
            //Arrange
            var initialCount = this.GetCount();
            var foo          = new FooArango {
                Id = Guid.NewGuid()
            };

            //Act
            this._repositoryWriter.Insert(foo);
            this._unitOfWork.SaveChanges();

            //Assert
            Assert.Equal(initialCount + 1, this.GetCount());
            Assert.Contains(foo, this.Contains(foo));
        }
Пример #2
0
        public void GetsItemById()
        {
            //Arrange
            var foo = new FooArango {
                Id = Guid.NewGuid()
            };

            this._repositoryWriter.Insert(foo);
            this._unitOfWork.SaveChanges();

            //Act
            var item = this._repositoryReader.GetById(foo.Id);

            //Assert
            Assert.Equal(foo, item);
        }
Пример #3
0
        public async Task GetsItemByIdAsync()
        {
            //Arrange
            var foo = new FooArango {
                Id = Guid.NewGuid()
            };

            await this._repositoryWriterAsync.InsertAsync(foo);

            await this._unitOfWork.SaveChangesAsync();

            //Act
            var item = await this._repositoryReaderAsync.GetByIdAsync(foo.Id);

            //Assert
            Assert.Equal(foo, item);
        }
Пример #4
0
        public async Task InsertsEntityAsync()
        {
            //Arrange
            var initialCount = this.GetCount();
            var foo          = new FooArango {
                Id = Guid.NewGuid()
            };

            //Act
            await this._repositoryWriterAsync.InsertAsync(foo);

            await this._unitOfWork.SaveChangesAsync();

            //Assert
            Assert.Equal(initialCount + 1, this.GetCount());
            Assert.Contains(foo, this.Contains(foo));
        }
Пример #5
0
        public void UpdatesEntity()
        {
            //Arrange
            var foo = new FooArango {
                Id = Guid.NewGuid(), Name = "A"
            };

            this._repositoryWriter.Insert(foo);
            this._unitOfWork.SaveChanges();

            //Act
            foo.Name = "B";
            this._repositoryWriter.Update(foo);
            this._unitOfWork.SaveChanges();
            var item = this._repositoryReader.GetById(foo.Id);

            //Assert
            Assert.Equal("B", item.Name);
        }
Пример #6
0
        public void DeletesEntityById()
        {
            //Arrange
            var foo = new FooArango {
                Id = Guid.NewGuid()
            };

            this._repositoryWriter.Insert(foo);
            this._unitOfWork.SaveChanges();
            var initialCount = this.GetCount();

            //Act
            this._repositoryWriter.Delete(foo.Id);
            this._unitOfWork.SaveChanges();

            //Assert
            Assert.Equal(initialCount - 1, this.GetCount());
            Assert.DoesNotContain(foo, this.Contains(foo));
        }
Пример #7
0
        public void InsertsRange()
        {
            //Arrange
            var initialCount = this.GetCount();
            var foo1         = new FooArango {
                Id = Guid.NewGuid()
            };
            var foo2 = new FooArango {
                Id = Guid.NewGuid()
            };

            //Act
            this._repositoryWriter.InsertRange(new[] { foo1, foo2 });
            this._unitOfWork.SaveChanges();

            //Assert
            Assert.Equal(initialCount + 2, this.GetCount());
            Assert.Contains(foo1, this.Contains(foo1));
            Assert.Contains(foo2, this.Contains(foo2));
        }
Пример #8
0
        public void GetsAll()
        {
            //Arrange
            this.DeleteAll();
            var foo1 = new FooArango {
                Id = Guid.NewGuid()
            };
            var foo2 = new FooArango {
                Id = Guid.NewGuid()
            };

            this._repositoryWriter.InsertRange(new[] { foo1, foo2 });
            this._unitOfWork.SaveChanges();

            //Act
            var items = this._repositoryReader.GetAll().ToArray();

            //Assert
            Assert.Contains(foo1, items);
            Assert.Contains(foo2, items);
        }
Пример #9
0
        public async Task UpdatesEntityAsync()
        {
            //Arrange
            var foo = new FooArango {
                Id = Guid.NewGuid(), Name = "A"
            };

            await this._repositoryWriterAsync.InsertAsync(foo);

            await this._unitOfWork.SaveChangesAsync();

            //Act
            foo.Name = "B";
            await this._repositoryWriterAsync.UpdateAsync(foo);

            await this._unitOfWork.SaveChangesAsync();

            var item = await this._repositoryReaderAsync.GetByIdAsync(foo.Id);

            //Assert
            Assert.Equal("B", item.Name);
        }
Пример #10
0
        public async Task GetsAllAsync()
        {
            //Arrange
            this.DeleteAll();
            var foo1 = new FooArango {
                Id = Guid.NewGuid()
            };
            var foo2 = new FooArango {
                Id = Guid.NewGuid()
            };

            await this._repositoryWriterAsync.InsertRangeAsync(new[] { foo1, foo2 });

            await this._unitOfWork.SaveChangesAsync();

            //Act
            var items = await this._repositoryReaderAsync.GetAllAsync();

            //Assert
            var foos = items as Foo[] ?? items.ToArray();

            Assert.Contains(foo1, foos);
            Assert.Contains(foo2, foos);
        }
Пример #11
0
 private IEnumerable <FooArango> Contains(FooArango item)
 {
     yield return(this._database.Query <FooArango>().FirstOrDefault(entity => entity.Id == item.Id));
 }