コード例 #1
0
ファイル: LocalClientTest.cs プロジェクト: VirtueMe/ravendb
 public void WaitForIndexing(EmbeddablDocumentStore store)
 {
     while (store.DocumentDatabase.Statistics.StaleIndexes.Length > 0)
     {
         Thread.Sleep(100);
     }
 }
コード例 #2
0
ファイル: OperationHeaders.cs プロジェクト: VirtueMe/ravendb
		public void CanPassOperationHeadersUsingEmbedded()
		{
            using (var documentStore = new EmbeddablDocumentStore
			{
				Configuration = new RavenConfiguration
				{
					Catalog =
						{
							Catalogs = { new TypeCatalog(typeof(RecordOperationHeaders)) }
						},
					DataDirectory = path,
					RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true
				}

			}.Initialize())
			{
				RecordOperationHeaders.Hello = null;
				using(var session = documentStore.OpenSession())
				{
                    session.Advanced.DatabaseCommands.OperationsHeaders["Hello"] = "World";
					session.Store(new { Bar = "foo"});
					session.SaveChanges();

					Assert.Equal("World", RecordOperationHeaders.Hello);
				}
			}
		}
コード例 #3
0
ファイル: DynamicDocuments.cs プロジェクト: VirtueMe/ravendb
        public void Can_Store_and_Load_Dynamic_Documents()
        {                                          
            //When running in the XUnit GUI strange things happen is we just create a path relative to 
            //the .exe itself, so make our folder in the System temp folder instead ("<user>\AppData\Local\Temp")
            string directoryName =  Path.Combine(Path.GetTempPath(), "ravendb.RavenDynamicDocs");
            IOExtensions.DeleteDirectory(directoryName);
            dynamic person = new CustomDynamicClass();
            person.FirstName = "Ellen";
            person.LastName = "Adams";

            dynamic employee = new ExpandoObject();
            employee.Name = "John Smith";
            employee.Age = 33;
            employee.Phones = new ExpandoObject();
            employee.Phones.Home = "0111 123123";
            employee.Phones.Office = "0772 321123";
            employee.Prices = new List<decimal>() { 123.4M, 123432.54M };

            using (var db = new EmbeddablDocumentStore() { DataDirectory = directoryName })
            {
                db.Initialize();
                
                using (var session = db.OpenSession())
                {
                    session.Store(employee);
                    string idEmployee = employee.Id;
                                        
                    session.Store(person);
                    string idPerson = person.Id;

                    //Check that a field called "Id" is added to the dynamic object (as it doesn't already exist)
                    //and that it has something in it (not null and not empty)
                    Assert.False(String.IsNullOrEmpty(idEmployee));
                    Assert.False(String.IsNullOrEmpty(idPerson));

                    session.SaveChanges();
                    session.Advanced.Clear();
                    //Pull the docs back out of RavenDB and see if the values are the same
                    dynamic employeeLoad = session.Load<dynamic>(idEmployee);
					Assert.Equal("John Smith", employeeLoad.Name);
					Assert.Equal("0111 123123", employeeLoad.Phones.Home);
					Assert.Equal("0772 321123", employeeLoad.Phones.Office);
					Assert.Contains(123.4D, employeeLoad.Prices);
					Assert.Contains(123432.54D, employeeLoad.Prices);
					Assert.Null(employeeLoad.Address);

                    dynamic personLoad = session.Load<dynamic>(idPerson);
					Assert.Equal("Ellen", personLoad.FirstName);
					Assert.Equal("Adams", personLoad.LastName);
					Assert.Null(personLoad.Age);

                }
            }
        }
コード例 #4
0
 protected DocumentStore NewDocumentStore()
 {
     var documentStore = new EmbeddablDocumentStore()
     {
         RunInMemory = true,
         Conventions =
         {
             FindTypeTagName = type => typeof(User).IsAssignableFrom(type) ? "users" : null
         }
     };
     RavenInstaller.DoInitialisation(null, documentStore);
     return documentStore;
 }
コード例 #5
0
ファイル: LocalClientTest.cs プロジェクト: VirtueMe/ravendb
        protected EmbeddablDocumentStore NewDocumentStore()
		{
			path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentStoreServerTests)).CodeBase);
			path = Path.Combine(path, "TestDb").Substring(6);

            IOExtensions.DeleteDirectory(path);

            var documentStore = new EmbeddablDocumentStore()
			{
				Configuration = new RavenConfiguration
				{
					DataDirectory = path,
					RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true
				}

			};
			documentStore.Initialize();
			return documentStore;
		}
コード例 #6
0
		public void WillNotSerializeEvents()
		{
            IOExtensions.DeleteDirectory("Data");
            try
			{
                using (var documentStore = new EmbeddablDocumentStore())
				{
					documentStore.Configuration.DataDirectory = "Data";
					documentStore.Conventions.CustomizeJsonSerializer = x => x.TypeNameHandling = TypeNameHandling.Auto;
					documentStore.Initialize();

					var bar = new Bar();
					var foo = new Foo();
					foo.PropertyChanged += bar.FooChanged;

					using (var session = documentStore.OpenSession())
					{
						session.Store(foo);
						session.SaveChanges();
					}
				}
			}
			finally
			{
                IOExtensions.DeleteDirectory("Data");
			}
		}