public void FindById_Finds() { var sprocket = new VersionedSprocket { Id = Guid.NewGuid(), Name = "FindMe" }; SprocketCollection.Insert(sprocket); SprocketRepo.Find(sprocket.Id).Name.Should().Be("FindMe"); }
public void Delete_Removes() { var sprocket = new VersionedSprocket { Id = Guid.NewGuid(), Name = "DeleteMe" }; SprocketCollection.Insert(sprocket); SprocketRepo.Delete(sprocket.Id); SprocketCollection.FindAll().Count(s => s.Id == sprocket.Id).Should().Be(0); }
public void StaleUpdate_ThrowsException() { var sprocket = new VersionedSprocket { Id = Guid.NewGuid(), Version = 1 }; SprocketCollection.Insert(sprocket); sprocket.Version = 0; sprocket.Name = "Saved"; SprocketRepo.Invoking(r => r.Update(sprocket)) .ShouldThrow <StaleObjectException>() .WithMessage("*VersionedSprocket*") .WithMessage("*updated by another transaction*"); sprocket.Version.Should().Be(0); }
public void Update_Saves() { var sprocket = new Sprocket { Id = Guid.NewGuid(), Name = "Outer", Sprockets = new[] { new Sprocket { Id = Guid.NewGuid(), Name = "Inner" } } }; SprocketCollection.Insert(sprocket); sprocket = SprocketCollection.AsQueryable().Single(s => s.Id == sprocket.Id); sprocket.Name = "Saved"; SprocketRepo.Update(sprocket); Sprocket found = SprocketCollection.AsQueryable().Single(s => s.Id == sprocket.Id); found.Name.Should().Be("Saved"); }