public async Task It_should_return_a_new_one_when_none_was_configured()
        {
            DocumentStore documentStore = null;

            try
            {
                documentStore = ConfigureEndpointRavenDBPersistence.GetDocumentStore();

                RavenSessionTestContext context =
                    await Scenario.Define <RavenSessionTestContext>(testContext => { })
                    .WithEndpoint <SharedRavenSessionExtensions>(b => b.When((bus, c) =>
                {
                    var sendOptions = new SendOptions();

                    sendOptions.RouteToThisEndpoint();

                    return(bus.Send(new SharedRavenSessionExtensions.GenericMessage(), sendOptions));
                }))
                    .Done(c => c.HandlerWasHit)
                    .Run();

                Assert.IsNotNull(context.RavenSessionFromHandler);
            }
            finally
            {
                if (documentStore != null)
                {
                    await ConfigureEndpointRavenDBPersistence.DeleteDatabase(documentStore.Database);
                }
            }
        }
        public async Task It_should_return_configured_session()
        {
            DocumentStore documentStore   = null;
            var           createdSessions = new List <IAsyncDocumentSession>();

            try
            {
                documentStore = ConfigureEndpointRavenDBPersistence.GetDocumentStore();

                RavenSessionTestContext context =
                    await Scenario.Define <RavenSessionTestContext>()
                    .WithEndpoint <SharedRavenSessionExtensions>(b =>
                                                                 b.CustomConfig(config =>
                {
                    config.UsePersistence <RavenDBPersistence>().UseSharedAsyncSession(_ =>
                    {
                        var session = documentStore.OpenAsyncSession();
                        createdSessions.Add(session);
                        return(session);
                    });
                })
                                                                 .When((bus, c) =>
                {
                    var sendOptions = new SendOptions();

                    sendOptions.RouteToThisEndpoint();

                    return(bus.Send(new SharedRavenSessionExtensions.GenericMessage(), sendOptions));
                }))
                    .Done(c => c.HandlerWasHit)
                    .Run();

                var injectedSessionId = ((InMemoryDocumentSessionOperations)context.RavenSessionFromHandler).Id;
                var found             = createdSessions.Cast <InMemoryDocumentSessionOperations>().Any(session => session.Id == injectedSessionId);
                Assert.IsTrue(found);
            }
            finally
            {
                foreach (var session in createdSessions)
                {
                    session.Dispose();
                }

                if (documentStore != null)
                {
                    await ConfigureEndpointRavenDBPersistence.DeleteDatabase(documentStore.Database);
                }
            }
        }
Esempio n. 3
0
        public async Task It_should_return_configured_session()
        {
            DocumentStore         documentStore = null;
            IAsyncDocumentSession session       = null;

            try
            {
                documentStore = ConfigureEndpointRavenDBPersistence.GetDocumentStore();
                session       = documentStore.OpenAsyncSession();

                RavenSessionTestContext context =
                    await Scenario.Define <RavenSessionTestContext>()
                    .WithEndpoint <SharedRavenSessionExtensions>(b =>
                                                                 b.CustomConfig(config =>
                {
                    config.UsePersistence <RavenDBPersistence>().UseSharedAsyncSession(_ => session);
                })
                                                                 .When((bus, c) =>
                {
                    var sendOptions = new SendOptions();

                    sendOptions.RouteToThisEndpoint();

                    return(bus.Send(new SharedRavenSessionExtensions.GenericMessage(), sendOptions));
                }))
                    .Done(c => c.HandlerWasHit)
                    .Run();

                Assert.AreSame(session, context.RavenSessionFromHandler);
            }
            finally
            {
                if (session != null)
                {
                    session.Dispose();
                    session = null;
                }

                if (documentStore != null)
                {
                    await ConfigureEndpointRavenDBPersistence.DeleteDatabase(documentStore.Database);
                }
            }
        }
 public SharedSessionGenericSaga(RavenSessionTestContext testContext, IAsyncDocumentSession ravenSession)
 {
     this.testContext  = testContext;
     this.ravenSession = ravenSession;
 }
Esempio n. 5
0
 public SessionExtensionGenericSaga(RavenSessionTestContext testContext)
 {
     this.testContext = testContext;
 }
 public GenericMessageHandler(RavenSessionTestContext testContext)
 {
     this.testContext = testContext;
 }
Esempio n. 7
0
 public SharedSessionGenericSaga(RavenSessionTestContext testContext)
 {
     this.testContext = testContext;
 }