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)); }
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); }
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); }
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)); }
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); }
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)); }
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)); }
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); }
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); }
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); }
private IEnumerable <FooArango> Contains(FooArango item) { yield return(this._database.Query <FooArango>().FirstOrDefault(entity => entity.Id == item.Id)); }