当前位置: 首页>>代码示例>>C#>>正文


C# SmugglerApi.Between方法代码示例

本文整理汇总了C#中Raven.Smuggler.SmugglerApi.Between方法的典型用法代码示例。如果您正苦于以下问题:C# SmugglerApi.Between方法的具体用法?C# SmugglerApi.Between怎么用?C# SmugglerApi.Between使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Raven.Smuggler.SmugglerApi的用法示例。


在下文中一共展示了SmugglerApi.Between方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SmugglerBetweenOperationShouldNotCreateDatabases

		public void SmugglerBetweenOperationShouldNotCreateDatabases()
		{
			using (var store = NewRemoteDocumentStore())
			{
				var smugglerApi = new SmugglerApi();

				var options = new SmugglerBetweenOptions
				              {
									From = new RavenConnectionStringOptions
					                {
						                Url = store.Url, 
										DefaultDatabase = "DB1"
					                },
									To = new RavenConnectionStringOptions
					                {
										Url = store.Url, 
										DefaultDatabase = "DB2"
					                }
				              };

				var aggregateException = Assert.Throws<AggregateException>(() => smugglerApi.Between(options).Wait());
				var exception = aggregateException.ExtractSingleInnerException();
				Assert.True(exception.Message.StartsWith("Smuggler does not support database creation (database 'DB1' on server"));

				store.DatabaseCommands.GlobalAdmin.EnsureDatabaseExists("DB1");

				aggregateException = Assert.Throws<AggregateException>(() => smugglerApi.Between(options).Wait());
				exception = aggregateException.ExtractSingleInnerException();
				Assert.True(exception.Message.StartsWith("Smuggler does not support database creation (database 'DB2' on server"));
			}
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:31,代码来源:RavenDB_2586.cs

示例2: ShouldSmuggleIdentitiesBetweenDatabases

		public async Task ShouldSmuggleIdentitiesBetweenDatabases()
		{
			using (var server1 = GetNewServer(port: 8079))
            using (var store1 = NewRemoteDocumentStore(ravenDbServer: server1, databaseName: "Database1"))
			{
                using (var session = store1.OpenAsyncSession("Database1"))
                {
                    await session.StoreAsync(new User {Id = "users/", Name = "Arek"});
                    await session.SaveChangesAsync();
                }

				store1.DatabaseCommands.SeedIdentityFor("users/", 10);

                using (var server2 = GetNewServer(port: 8078))
                {
					using (var store2 = NewRemoteDocumentStore(ravenDbServer: server2, databaseName: "Database2"))
					{
						var smugglerApi = new SmugglerApi();
						await smugglerApi.Between(new SmugglerBetweenOptions
						{
							From = new RavenConnectionStringOptions {Url = "http://localhost:8079", DefaultDatabase = "Database1"},
							To = new RavenConnectionStringOptions {Url = "http://localhost:8078", DefaultDatabase = "Database2"}
						});
                    
                        using (var session = store2.OpenAsyncSession("Database2"))
                        {
							await session.StoreAsync(new User { Id = "users/", Name = "Oren" });
							await session.SaveChangesAsync();
                        }

						var documents = (await store2.AsyncDatabaseCommands.GetDocumentsAsync(0, 10)).OrderBy(x => x.Key).ToArray();

						Assert.Equal(2, documents.Length);
						Assert.Equal("users/1", documents[0].Key);
						Assert.Equal("users/11", documents[1].Key);
					}
                }
            }
		}
开发者ID:kijanawoodard,项目名称:ravendb,代码行数:39,代码来源:RavenDB_2764.cs

示例3: CanUseBetween

        public async Task CanUseBetween()
        {
            using (var server1 = new RavenDbServer(new RavenConfiguration()
            {
                Port = Port1,
                ServerName = ServerName1
            })
            {
                RunInMemory = true,
                UseEmbeddedHttpServer = true
            }.Initialize())
            {
                var doc = MultiDatabase.CreateDatabaseDocument("db1");
                ((ServerClient)server1.DocumentStore.DatabaseCommands.ForSystemDatabase()).GlobalAdmin.CreateDatabase(doc);

                using (var store1 = new DocumentStore
                {
                    Url = "http://localhost:" + Port1,
                    DefaultDatabase = "db1"
                }.Initialize())
                {
                    new Users_ByName().Execute(store1);
                    new UsersTransformer().Execute(store1);

                    using (var session = store1.OpenSession("db1"))
                    {
                        session.Store(new User { Name = "Name1", LastName = "LastName1" });
                        session.Store(new User { Name = "Name2", LastName = "LastName2" });
                        session.SaveChanges();
                    }

                    store1.DatabaseCommands.PutAttachment("attachement1", null, new MemoryStream(new byte[] { 3 }), new RavenJObject());

                    using (var server2 = new RavenDbServer(new RavenConfiguration()
                    {
                        Port = Port2,
                        ServerName = ServerName2
                    })
                    {
                        RunInMemory = true,
                        UseEmbeddedHttpServer = true
                    }.Initialize())
                    {
                        var doc2 = MultiDatabase.CreateDatabaseDocument("db2");
                        ((ServerClient)server2.DocumentStore.DatabaseCommands.ForSystemDatabase()).GlobalAdmin.CreateDatabase(doc2);

                        using (var store2 = new DocumentStore
                        {
                            Url = "http://localhost:" + Port2,
                            DefaultDatabase = "db2"
                        }.Initialize())
                        {

                            var smugglerApi = new SmugglerApi();
                            await smugglerApi.Between(new SmugglerBetweenOptions
                            {
                                From = new RavenConnectionStringOptions { Url = "http://localhost:" + Port1, DefaultDatabase = "db1" },
                                To = new RavenConnectionStringOptions { Url = "http://localhost:" + Port2, DefaultDatabase = "db2" }
                            });

                            var docs = store2.DatabaseCommands.GetDocuments(0, 10);
                            Assert.Equal(3, docs.Length);
                            var indexes = store2.DatabaseCommands.GetIndexes(0,10);
                            Assert.Equal(1, indexes.Length);
                            var transformers = store2.DatabaseCommands.GetTransformers(0, 10);
                            Assert.Equal(1, transformers.Length);
                            var attachments = store2.DatabaseCommands.GetAttachments(0, new Etag(), 10);
                            Assert.Equal(1, attachments.Length);

                        }
                    }
                }
            }
        }
开发者ID:kijanawoodard,项目名称:ravendb,代码行数:74,代码来源:SmugglerApiTests.cs


注:本文中的Raven.Smuggler.SmugglerApi.Between方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。