public static async Task Assert(this ProjectionTestSpecification <IAsyncDocumentSession> specification) { if (specification == null) { throw new ArgumentNullException("specification"); } using (var store = new EmbeddableDocumentStore { RunInMemory = true, DataDirectory = Path.GetTempPath() }) { store.Configuration.Storage.Voron.AllowOn32Bits = true; store.Initialize(); using (var session = store.OpenAsyncSession()) { await new Projector <IAsyncDocumentSession>(specification.Resolver). ProjectAsync(session, specification.Messages); await session.SaveChangesAsync(); var result = await specification.Verification(session, CancellationToken.None); if (result.Failed) { throw new AssertionException(result.Message); } } } }
public static void Main(string[] args) { var container = TinyIoCContainer.Current; var eventStore = new JsonFileEventStore("ExampleEvents.zip", 100); EmbeddableDocumentStore store = BuildDocumentStore(".\\", 9001); container.Register <Func <IAsyncDocumentSession> >(() => store.OpenAsyncSession()); var dispatcher = new Dispatcher(eventStore); var bootstrapper = new CountsProjector(dispatcher, store.OpenAsyncSession); var startOptions = new StartOptions($"http://localhost:9000"); using (WebApp.Start(startOptions, builder => builder.UseControllers(container))) { bootstrapper.Start().Wait(); Console.WriteLine($"HTTP endpoint available at http://localhost:9000/api/Statistics/CountsPerState"); Console.WriteLine($"Management Studio available at http://localhost:9001"); Console.ReadLine(); } }
public async Task CanRefreshEntityFromDatabaseAsync() { var company = new Company { Name = "Company Name" }; using (var session = documentStore.OpenAsyncSession()) { await session.StoreAsync(company); await session.SaveChangesAsync(); using (var session2 = documentStore.OpenSession()) { var company2 = session2.Load <Company>(company.Id); company2.Name = "Hibernating Rhinos"; session2.Store(company2); session2.SaveChanges(); } var old = session.Advanced.GetEtagFor(company); await session.Advanced.RefreshAsync(company); Assert.NotEqual(old, session.Advanced.GetEtagFor(company)); Assert.NotEqual(Etag.Empty, session.Advanced.GetEtagFor(company)); Assert.Equal("Hibernating Rhinos", company.Name); } }
public async void Show() { using (var store = new EmbeddableDocumentStore { RunInMemory = true, DataDirectory = Path.GetTempPath() }) { store.Initialize(); using (var session = store.OpenAsyncSession()) { var portfolioId = Guid.NewGuid(); await new AsyncRavenProjector(Projection.Handlers). ProjectAsync(session, new object[] { new PortfolioAdded { Id = portfolioId, Name = "My portfolio" }, new PortfolioRenamed { Id = portfolioId, Name = "Your portfolio" }, new PortfolioRemoved { Id = portfolioId } }); } } }
public async Task Show() { using (var store = new EmbeddableDocumentStore { RunInMemory = true, DataDirectory = Path.GetTempPath() }) { store.Initialize(); using (var session = store.OpenAsyncSession()) { var portfolioId = Guid.NewGuid(); await new Projector <IAsyncDocumentSession>(Resolve.WhenEqualToHandlerMessageType(Projection.Handlers)). ProjectAsync(session, new object[] { new PortfolioAdded { Id = portfolioId, Name = "My portfolio" }, new PortfolioRenamed { Id = portfolioId, Name = "Your portfolio" }, new PortfolioRemoved { Id = portfolioId } }); } } }
public void SetUp() { _store = new EmbeddableDocumentStore { RunInMemory = true, DataDirectory = Path.GetTempPath() }; _store.Initialize(); _session = _store.OpenAsyncSession(); }
public void TestInitialize() { // Arrange _documentStore = new EmbeddableDocumentStore { ConnectionStringName = "RavenDB" }; _documentStore.Initialize(); _session = _documentStore.OpenAsyncSession(); _controller = new MoviesController(_session); }
public async Task SpatialIndexTest() { using (EmbeddableDocumentStore db = NewDocumentStore()) { new Promos_Index().Execute(db); using (IAsyncDocumentSession session = db.OpenAsyncSession()) { await session.StoreAsync(new Promo { Title = "IPHONES", Coordinate = new Coordinate { latitude = 41.145556, longitude = -73.995 } }); await session.StoreAsync(new Promo { Title = "ANDROIDS", Coordinate = new Coordinate { latitude = 41.145533, longitude = -73.999 } }); await session.StoreAsync(new Promo { Title = "BLACKBERRY", Coordinate = new Coordinate { latitude = 12.233, longitude = -73.995 } }); await session.SaveChangesAsync(); WaitForIndexing(db); var result = await session.Query <Promo, Promos_Index>() .Customize( x => x.WithinRadiusOf( radius: 3.0, latitude: 41.145556, longitude: -73.995)) .ToListAsync(); Assert.Equal(2, result.Count); } } }
protected async Task ExecuteAction <TController>(Func <TController, Task> action) where TController : DragonContractsController, new() { var controller = new TController { Session = documentStore.OpenAsyncSession() }; //var httpConfiguration = MockRepository.GenerateStub<HttpConfiguration>(); //var httpRouteData = MockRepository.GenerateStub<HttpRouteData>(); //var httpRequestMessage = MockRepository.GenerateStub<HttpRequestMessage>(); //ControllerContext = new HttpControllerContext(httpConfiguration, httpRouteData, httpRequestMessage); //controller.ControllerContext = ControllerContext; await action(controller); await controller.Session.SaveChangesAsync(); }
public void SetUp() { _store = new EmbeddableDocumentStore { RunInMemory = true, DataDirectory = Path.GetTempPath() }; _store.Initialize(); _session = _store.OpenAsyncSession(); _calls = new List <RavenProjectionHandlerCall>(); var handler = new RavenProjectionHandler( typeof(MatchMessage1), (session, msg, token) => { _calls.Add(new RavenProjectionHandlerCall(session, msg, token)); return(Task.FromResult(false)); }); _sut = SutFactory(new[] { handler }); }
public async Task When_delete_revision_and_load_Then_should_get_null() { using (var session = _documentStore.OpenAsyncSession()) { var doc = new RevisionedDocument { Id = "key", Revision = 1, Data = "Alpha" }; await session.StoreAsync(doc); await session.SaveChangesAsync(); } await _documentStore.AsyncDatabaseCommands.DeleteRevision("key", 1, null); using (var session = _documentStore.OpenAsyncSession()) { Assert.Null(await session.LoadRevision <RevisionedDocument>("key", 1)); } }
public IAsyncDocumentSession OpenAsyncSession() { return(_documentStore.OpenAsyncSession()); }