public void VariableManager_get_defined_variable_should_return_all_values()
        {
            var store = new Raven.Client.Embedded.EmbeddableDocumentStore
            {
                RunInMemory = true
            };

            store.Initialize();
            IndexCreation.CreateIndexes(typeof(VariablesByName).Assembly, store);

            using (var session = store.OpenSession())
            {
                session.Store(new Variable
                    {
                        Name = "Operators",
                        Values = new List<string> { "CompileThis", "Defize" }
                    });

                session.SaveChanges();
            }

            using (var session = store.OpenSession())
            {
                var vm = new VariableManager(session);

                var x = vm.GetValues("Operators");

                x.Should().HaveCount(c => c == 2);
            }
        }
示例#2
0
        public IDocumentStore CreateDocumentStore()
        {
            var parser = ConnectionStringParser<RavenConnectionStringOptions>
                .FromConnectionStringName("RavenDB");
            parser.Parse();

            // If we're configured to run in memory, we're debug; running locally.
            // Otherwise, we're live, connect to the real database on AppHarbor.
            var store = default(IDocumentStore);
            var isLocal = parser.ConnectionStringOptions.Url.Contains("localhost");
            if (isLocal)
            {
                store = new Raven.Client.Embedded.EmbeddableDocumentStore
                {
                    RunInMemory = true
                };
            }
            else
            {
                store = new DocumentStore
                {
                    ApiKey = parser.ConnectionStringOptions.ApiKey,
                    Url = parser.ConnectionStringOptions.Url,
                };
            }

            store.Initialize();
            IndexCreation.CreateIndexes(typeof(RavenStore).Assembly, store);
            return store;
        }
示例#3
0
文件: Everett.cs 项目: ybdev/ravendb
        private void TestScenario(Raven.Client.Embedded.EmbeddableDocumentStore store)
        {
            using (var session = store.OpenSession())
            {
                session.Store(new Dealer {
                    Id = "accounts/1", Name = "Dealer"
                });
                session.Store(new Customer {
                    Id = "accounts/2", Name = "Customer", DealerId = "accounts/1"
                });
                session.Store(new ClickTransaction
                {
                    AccountId  = "accounts/2",
                    Date       = DateTime.Today,
                    Quantity   = 100,
                    Type       = "Debit",
                    DesignName = "N009876",
                    UserEmail  = "*****@*****.**"
                });
                session.SaveChanges();
            }

            WaitForIndexing(store);

            using (var session = store.OpenSession())
            {
                var result = session.Advanced.LuceneQuery <ClickTransactionDailyDebitReportResult, ClickTransactions_DailyDebitReport>()
                             .WaitForNonStaleResultsAsOfNow()
                             .ToArray()
                             .FirstOrDefault();

                Assert.Equal("Dealer", result.AccountDealerName);
            }
        }
        public void Init()
        {
            var embeddedSore = new Raven.Client.Embedded.EmbeddableDocumentStore
            {
                DataDirectory = @"~\..\RavenDB\Data"
            }.Initialize();

            Configure.Instance.DefiningMessagesAs(t => t.Namespace != null && t.Namespace == "NSB04SampleMessages");
            Configure.Instance.RavenPersistenceWithStore(embeddedSore);
        }
        public void Init()
        {
            var embeddedSore = new Raven.Client.Embedded.EmbeddableDocumentStore
            {
                DataDirectory = @"~\..\RavenDB\Data"
            }.Initialize();

            Configure.Instance.DefiningMessagesAs(t => t.Namespace != null && t.Namespace == "NSB04SampleMessages");
            Configure.Instance.RavenPersistenceWithStore(embeddedSore);
        }
示例#6
0
        static void Main(string[] args)
        {
            var documentStore = new Raven.Client.Embedded.EmbeddableDocumentStore { ConnectionStringName = "RavenDB" };
            documentStore.Initialize();

            var session = documentStore.OpenSession();

            documentStore.DatabaseCommands.DeleteByIndex("Raven/DocumentsByEntityName",
                                             new IndexQuery
                                             {
                                                 Query = session.Advanced.LuceneQuery<object>()
                                                 .WhereEquals("Tag", "Posts")
                                                 .ToString()
                                             },
                                             false);

            StreamReader re = File.OpenText("Data.txt");

            JsonTextReader reader = new JsonTextReader(re);
            JArray root = JArray.Load(reader);

            foreach (JObject o in root)
            {
                Post post = new Post();
                post.Id = o["Id"].ToObject<string>();
                post.Title = o["Title"].ToObject<string>();
                post.DateCreated = o["DateCreated"].ToObject<DateTime>();
                post.Body = "<p>"+o["Body"].ToObject<string>()+"</p>";

                if (o["Tags"] != null)
                {
                    List<string> tags = new List<string>();
                    var strippedData = o["Tags"].ToObject<string>().Split(',');
                    foreach (string s in strippedData)
                    {
                        tags.Add(s.Trim());
                    }

                    post.Tags = tags;
                }
                else
                {
                    post.Tags = null;
                }

                post.Published = o["Published"].ToObject<bool>();

                session.Store(post);

            }

            session.SaveChanges();
            Console.WriteLine("Data Imported");
            Console.ReadKey();
        }
        public void Init()
        {
            var embeddedSore = new Raven.Client.Embedded.EmbeddableDocumentStore
            {
                DataDirectory = @"~\..\RavenDB\Data"
            }.Initialize();

            Configure.Instance.DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Commands"));
            Configure.Instance.DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Events"));
            Configure.Instance.RavenPersistenceWithStore(embeddedSore);
        }
		public void Init()
		{
			var embeddedSore = new Raven.Client.Embedded.EmbeddableDocumentStore
			{
				DataDirectory = @"~\..\RavenDB\Data"
			}.Initialize();

			Configure.Instance.DefiningCommandsAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Commands" ) );
			Configure.Instance.DefiningEventsAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Events" ) );
			Configure.Instance.RavenPersistenceWithStore( embeddedSore );
		}
示例#9
0
        public void Init()
        {
            var embeddedSore = new Raven.Client.Embedded.EmbeddableDocumentStore
            {
                DataDirectory = @"~\..\RavenDB\Data"
            }.Initialize();

            Configure.Instance.DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Commands"));
            Configure.Instance.DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Events"));
            Configure.Instance.RavenPersistenceWithStore(embeddedSore);

            var s = typeof(NServiceBus.IWcfService <NSB09WcfIntegration.Messages.Commands.MyCommand, NSB09WcfIntegration.Messages.MyResponse>).ToString();
        }
        public void Init()
        {
            var embeddedSore = new Raven.Client.Embedded.EmbeddableDocumentStore
            {
                DataDirectory = @"~\..\RavenDB\Data"
            }.Initialize();

            Configure.Instance.DefiningCommandsAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Commands" ) );
            Configure.Instance.DefiningEventsAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Events" ) );
            Configure.Instance.RavenPersistenceWithStore( embeddedSore );

            var s = typeof(NServiceBus.IWcfService<NSB09WcfIntegration.Messages.Commands.MyCommand, NSB09WcfIntegration.Messages.MyResponse>).ToString();
        }
示例#11
0
文件: Everett.cs 项目: ybdev/ravendb
        protected override void ModifyStore(Raven.Client.Embedded.EmbeddableDocumentStore documentStore)
        {
            base.ModifyStore(documentStore);
            documentStore.Conventions = new DocumentConvention
            {
                CustomizeJsonSerializer    = serializer => serializer.TypeNameHandling = TypeNameHandling.All,
                DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites,
                FindTypeTagName            = type =>
                {
                    if (typeof(Account).IsAssignableFrom(type))
                    {
                        return("Accounts");
                    }

                    return(DocumentConvention.DefaultTypeTagName(type));
                },
            };
        }
示例#12
0
        public void ConfigureRavenDb(Container container)
        {
            //NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080);

            var documentStore =
                new Raven.Client.Embedded.EmbeddableDocumentStore()
            {
                UseEmbeddedHttpServer = true
            }
            .Initialize();


            IndexCreation.CreateIndexes(GetType().Assembly, documentStore);

            container.Register(documentStore);

            container.Register(c => c.Resolve <IDocumentStore>().OpenSession())
            .ReusedWithin(ReuseScope.Request);
        }
        public void VariableManager_query_missing_variable_should_return_null()
        {
            var store = new Raven.Client.Embedded.EmbeddableDocumentStore
                {
                    RunInMemory = true
                };

            store.Initialize();
            IndexCreation.CreateIndexes(typeof(VariablesByName).Assembly, store);

            using (var session = store.OpenSession())
            {
                var vm = new VariableManager(session);

                var x = vm.GetRandomValue("Operators");

                x.Should().BeNull();
            }
        }
示例#14
0
        public void BootstrapContainer()
        {
            var container = new WindsorContainer();

            container.Register(Classes.FromThisAssembly().BasedOn<IController>().LifestyleTransient());
            container.Register(Component.For<IDocumentStore>().UsingFactoryMethod((k, c) => {
                var store = new Raven.Client.Embedded.EmbeddableDocumentStore() { DataDirectory = "App_Data" };
                store.Initialize();
                return store;
            }));
            container.Register(Component.For<IDocumentSession>().UsingFactoryMethod((k, c) => k.Resolve<IDocumentStore>().OpenSession()).LifestylePerWebRequest());

            //mediator
            container.Register(Component.For<IMediator>().Instance(new Mediator(t => container.Resolve(t), t => container.ResolveAll(t).Cast<object>().ToArray())));
            container.Register(Classes.FromAssemblyContaining<AddNewUserCommandHandler>().BasedOn(typeof(MediatR.IRequestHandler<,>)).WithServiceAllInterfaces().LifestylePerWebRequest());
            container.Register(Classes.FromAssemblyContaining<AddNewUserCommandHandler>().BasedOn(typeof(MediatR.IAsyncRequestHandler<,>)).WithServiceAllInterfaces().LifestylePerWebRequest());

            ControllerBuilder.Current.SetControllerFactory(new WindowControllerFactory(container));
        }
示例#15
0
		static void Main( string[] args )
		{
			var embeddedSore = new Raven.Client.Embedded.EmbeddableDocumentStore
			{
				DataDirectory = @"~\..\RavenDB\Data"
			}.Initialize();

			var startableBus = NServiceBus.Configure.With()
							.DefaultBuilder()
							.Log4Net()
							.DefiningCommandsAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Commands" ) )
							.DefiningEventsAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Events" ) )
							.RavenPersistenceWithStore( embeddedSore )
							.UnicastBus()
							.LoadMessageHandlers()
							.CreateBus();

			var bus = startableBus.Start();

			Console.Read();

			startableBus.Dispose();
		}
示例#16
0
        static void Main(string[] args)
        {
            var embeddedSore = new Raven.Client.Embedded.EmbeddableDocumentStore
            {
                DataDirectory = @"~\..\RavenDB\Data"
            }.Initialize();

            var startableBus = NServiceBus.Configure.With()
                               .DefaultBuilder()
                               .Log4Net()
                               .DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Commands"))
                               .DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Events"))
                               .RavenPersistenceWithStore(embeddedSore)
                               .UnicastBus()
                               .LoadMessageHandlers()
                               .CreateBus();

            var bus = startableBus.Start();

            Console.Read();

            startableBus.Dispose();
        }
示例#17
0
        public void BootstrapContainer()
        {
            var container = new WindsorContainer();

            container.Register(Classes.FromThisAssembly().BasedOn <IController>().LifestyleTransient());
            container.Register(Component.For <IDocumentStore>().UsingFactoryMethod((k, c) => {
                var store = new Raven.Client.Embedded.EmbeddableDocumentStore()
                {
                    DataDirectory = "App_Data"
                };
                store.Initialize();
                return(store);
            }));
            container.Register(Component.For <IDocumentSession>().UsingFactoryMethod((k, c) => k.Resolve <IDocumentStore>().OpenSession()).LifestylePerWebRequest());

            //mediator
            container.Register(Component.For <IMediator>().Instance(new Mediator(t => container.Resolve(t), t => container.ResolveAll(t).Cast <object>().ToArray())));
            container.Register(Classes.FromAssemblyContaining <AddNewUserCommandHandler>().BasedOn(typeof(MediatR.IRequestHandler <,>)).WithServiceAllInterfaces().LifestylePerWebRequest());
            container.Register(Classes.FromAssemblyContaining <AddNewUserCommandHandler>().BasedOn(typeof(MediatR.IAsyncRequestHandler <,>)).WithServiceAllInterfaces().LifestylePerWebRequest());


            ControllerBuilder.Current.SetControllerFactory(new WindowControllerFactory(container));
        }
示例#18
0
        public void ConfigureRavenDb(Container container)
        {
            //NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080);

            var documentStore =
                new Raven.Client.Embedded.EmbeddableDocumentStore()
                    {
                        UseEmbeddedHttpServer = true
                    }
                    .Initialize();


            IndexCreation.CreateIndexes(GetType().Assembly, documentStore);

            container.Register(documentStore);

            container.Register(c => c.Resolve<IDocumentStore>().OpenSession())
                     .ReusedWithin(ReuseScope.Request);

        }