private void RequireUserExists(Guid user) { using (var uow = new UnitOfWork()) { if (!uow.Query<User>().Exists(user)) throw new ArgumentException("Unknown user", "user"); } }
public void should_convert_collection_to_capped() { const int mb10 = 10 * 1024 * 1024; using (new UnitOfWork()) { TestRoot.Create("boo"); TestRoot.Create("hoo"); } using (var uow = new UnitOfWork()) { var database = (MongoDatabase)uow.DomainDataSession.DataSession.NativeSession; database.EnsureCappedCollectionExists<TestRoot>(10); var stats = database.GetCollection<TestRoot>().GetStats(); stats.IsCapped.Should().BeTrue(); stats.StorageSize.Should().BeInRange(mb10, mb10 + 8192); //TODO: get exact metadata size? uow.Query<TestRoot>().Count().Should().Be(2); } }
public void should_return_valid_object() { TestRoot createdRoot; using (new UnitOfWork()) { createdRoot = TestRoot.Create("test data"); } using (var uow = new UnitOfWork()) { var foundRoot = uow.Query<TestRoot>().GetOne(createdRoot.Id); foundRoot.Id.Should().Be(createdRoot.Id); foundRoot.Data.Should().Be(createdRoot.Data); } }