public void can_use_RavenDB_in_a_remote_process_for_batch_operations() { var documentConvention = new DocumentConvention(); using (var driver = new RavenDBDriver("HelloShard", documentConvention)) { driver.Start(); using (var store = new DocumentStore { Url = driver.Url, Conventions = documentConvention }) { store.Initialize(); using (var session = store.OpenSession()) { store.DatabaseCommands.Batch(new[] { GetPutCommand() }); session.SaveChanges(); } } using (var store = driver.GetDocumentStore()) { should_find_expected_value_in(store); } } }
public void can_use_RavenDB_in_a_remote_process() { var documentConvention = new DocumentConvention(); using (var driver = new RavenDBDriver("HelloShard", documentConvention)) { driver.Start(); using (var store = new DocumentStore { Url = driver.Url, Conventions = documentConvention }) { store.Initialize(); using (var session = store.OpenSession()) { session.Store(new Tuple<string, string>("hello", "world")); session.SaveChanges(); } } using (var store = driver.GetDocumentStore()) { should_find_expected_value_in(store); } } }
public void can_use_RavenDB_in_a_remote_process_to_post_batch_operations() { var documentConvention = new DocumentConvention(); using (var driver = new RavenDBDriver("HelloShard", documentConvention)) { driver.Start(); var httpWebRequest = (HttpWebRequest)WebRequest.Create(new Uri(new Uri(driver.Url), "bulk_docs")); httpWebRequest.Method = "POST"; using (var requestStream = new StreamWriter(httpWebRequest.GetRequestStream(), Encoding.UTF8)) { requestStream.Write("["); requestStream.Write(GetPutCommand().ToJson().ToString()); requestStream.Write("]"); } HttpWebResponse webResponse; try { webResponse = (HttpWebResponse)httpWebRequest.GetResponse(); webResponse.Close(); } catch (WebException e) { driver.Should_finish_without_error(); driver.TraceExistingOutput(); Console.WriteLine(new StreamReader(e.Response.GetResponseStream()).ReadToEnd()); throw; } using (var store = driver.GetDocumentStore()) { should_find_expected_value_in(store); } } }