public void CanCreateRepository() { using (var database = new MongoDbTest()) { var repository = new Repository<ToDoItem>(database.Database); } }
public void CanCount() { using (var database = new MongoDbTest()) { var repository = new Repository<ToDoItem>(database.Database); var item = new ToDoItem() { Item = "Item", Title = "Title" }; item = repository.Insert(item); Assert.NotNull(item); Assert.Equal(1, repository.Count(e => e.Title == "Title")); Assert.Equal(0, repository.Count(e => e.Title == "test")); } }
public void CanAny() { using (var database = new MongoDbTest()) { var repository = new Repository<ToDoItem>(database.Database); var item = new ToDoItem() { Item = "Item", Title = "Title" }; item = repository.Insert(item); Assert.NotNull(item); Assert.True(repository.Any(e => e.Title == "Title")); Assert.False(repository.Any(e => e.Title == "test")); } }
public void CanDelete() { using (var database = new MongoDbTest()) { var repository = new Repository<ToDoItem>(database.Database); var item = new ToDoItem() { Item = "Item", Title = "Title" }; item = repository.Insert(item); Assert.NotNull(item); Assert.NotNull(repository.Delete(item)); Assert.Null(repository.ById(item.Id)); } }
public void CanFind() { using (var database = new MongoDbTest()) { var repository = new Repository<ToDoItem>(database.Database); var item = new ToDoItem() { Item = "Item", Title = "Title" }; item = repository.Insert(item); Assert.NotNull(item); var result = repository.Find(e => e.Title == "Title"); Assert.NotNull(result); Assert.Single(result); result = repository.Find(e => e.Title == "test"); Assert.NotNull(result); Assert.Empty(result); } }
public void CanUpdate() { using (var database = new MongoDbTest()) { var repository = new Repository<ToDoItem>(database.Database); var item = new ToDoItem() { Item = "Item", Title = "Title" }; item = repository.Insert(item); Assert.NotNull(item); item.Title = "Changed"; repository.Update(item); item = repository.ById(item.Id); Assert.Equal("Changed", item.Title); } }