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


C# Mocks.MSolrConnection类代码示例

本文整理汇总了C#中SolrNet.Tests.Mocks.MSolrConnection的典型用法代码示例。如果您正苦于以下问题:C# MSolrConnection类的具体用法?C# MSolrConnection怎么用?C# MSolrConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MSolrConnection类属于SolrNet.Tests.Mocks命名空间,在下文中一共展示了MSolrConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CommitWithParams

 public void CommitWithParams() {
     var conn = new MSolrConnection();
     conn.post &= x => x.Args("/update", "<commit waitSearcher=\"true\" waitFlush=\"true\" />").Expect(1);
     Solr.Connection = conn;
     Solr.Commit(true, true);
     conn.post.Verify();
 }
开发者ID:FilipVV,项目名称:SolrNet,代码行数:7,代码来源:DSLTests.cs

示例2: Commit

 public void Commit() {
     var conn = new MSolrConnection();
     conn.post &= x => x.Args("/update", "<commit />").Expect(1);
     Solr.Connection = conn;
     Solr.Commit();
     conn.post.Verify();
 }
开发者ID:FilipVV,项目名称:SolrNet,代码行数:7,代码来源:DSLTests.cs

示例3: Add

 public void Add() {
     var conn = new MSolrConnection();
     conn.post &= x => x.Args("/update", "<add><doc /></add>").Expect(1);
     Solr.Connection = conn;
     Solr.Add(new TestDocument());
     conn.post.Verify();
 }
开发者ID:FilipVV,项目名称:SolrNet,代码行数:7,代码来源:DSLTests.cs

示例4: DeleteByMultipleId

 public void DeleteByMultipleId() {
     var ids = new[] {"123", "456"};
     var conn = new Mocks.MSolrConnection();
     var xml = string.Format("<delete><id>{0}</id><id>{1}</id></delete>", ids[0], ids[1]);
     conn.post = conn.post.Args("/update", xml);
     var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(ids, null, null), null);
     cmd.Execute(conn);
     Assert.AreEqual(1, conn.post.Calls);
 }
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:9,代码来源:DeleteCommandTests.cs

示例5: DeleteById

		public void DeleteById() {
			const string id = "123123";
		    var conn = new Mocks.MSolrConnection();
		    conn.post = conn.post
		        .Args("/update", string.Format("<delete><id>{0}</id></delete>", id));
            var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(new[] { id }, null, null), null);
            cmd.Execute(conn);
            Assert.AreEqual(1, conn.post.Calls);
        }
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:9,代码来源:DeleteCommandTests.cs

示例6: DocumentAddParametersOverwriteSpecifiedTrue

 public void DocumentAddParametersOverwriteSpecifiedTrue()
 {
     var docSerializer = new SolrDocumentSerializer<TestDocWithString>(new AttributesMappingManager(), new DefaultFieldSerializer());
     var conn = new Mocks.MSolrConnection();
     conn.post = conn.post
         .Args("/update", "<add overwrite=\"true\"><doc boost=\"2.1\" /></add>");
     var docs = new[] { new KeyValuePair<TestDocWithString, double?>(new TestDocWithString(), 2.1) };
     var parameters = new AddParameters { Overwrite = true };
     var cmd = new AddCommand<TestDocWithString>(docs, docSerializer, parameters);
     cmd.Execute(conn);
     Assert.AreEqual(1, conn.post.Calls);
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:12,代码来源:AddCommandTests.cs

示例7: ExecuteWithBasicOptions

 public void ExecuteWithBasicOptions() {
     var conn = new Mocks.MSolrConnection();
     conn.post += (url, content) => {
         Assert.AreEqual("/update", url);
         Assert.AreEqual("<commit waitSearcher=\"true\" waitFlush=\"true\" />", content);
         Console.WriteLine(content);
         return null;
     };
     var cmd = new CommitCommand { WaitFlush = true, WaitSearcher = true };
     cmd.Execute(conn);
     Assert.AreEqual(1, conn.post.Calls);
 }
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:12,代码来源:CommitCommandTests.cs

示例8: ExecuteBasic

 public void ExecuteBasic() {
     var conn = new Mocks.MSolrConnection();
     conn.post += (url, content) => {
         Assert.AreEqual("/update", url);
         Assert.AreEqual("<commit />", content);
         Console.WriteLine(content);
         return null;
     };
     var cmd = new CommitCommand();
     cmd.Execute(conn);
     Assert.AreEqual(1, conn.post.Calls);
 }
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:12,代码来源:CommitCommandTests.cs

示例9: ExecuteWithAllParameters

        public void ExecuteWithAllParameters()
        {
            var parameters = new ExtractParameters(null, "1", "text.doc");
            var conn = new MSolrConnection();
            conn.postStream += (url, type, stream, kvs) => {
                Assert.AreEqual("/update/extract", url);
                Assert.AreEqual("application/word-document", type);

                var p = new[] {
                    KV.Create("literal.id", parameters.Id),
                    KV.Create("resource.name", parameters.ResourceName),
                    KV.Create("literal.field1", "value1"),
                    KV.Create("literal.field2", "value2"),
                    KV.Create("stream.type", "application/word-document"),
                    KV.Create("commit", "true"),
                    KV.Create("uprefix", "pref"),
                    KV.Create("defaultField", "field1"),
                    KV.Create("extractOnly", "true"),
                    KV.Create("extractFormat", "text"),
                    KV.Create("capture", "html"),
                    KV.Create("captureAttr", "true"),
                    KV.Create("xpath", "body"),
                    KV.Create("lowernames", "true")
                };

                CollectionAssert.AreEquivalent(p, kvs);
                return "";
            };

            var cmd = new ExtractCommand(new ExtractParameters(null, "1", "text.doc") {
                AutoCommit = true,
                Capture = "html",
                CaptureAttributes = true,
                DefaultField = "field1",
                ExtractOnly = true,
                ExtractFormat = ExtractFormat.Text,
                Fields = new[] {
                    new ExtractField("field1", "value1"),
                    new ExtractField("field2", "value2")
                },
                LowerNames = true,
                XPath = "body",
                Prefix = "pref",
                StreamType = "application/word-document"
            });
            cmd.Execute(conn);
            Assert.AreEqual(1, conn.postStream.Calls);
        }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:48,代码来源:ExtractCommandTests.cs

示例10: AddWithBoost

        public void AddWithBoost()
        {
            var connection = new MSolrConnection();
            connection.post += (url, content) => {
                Assert.AreEqual("/update", url);
                Assert.AreEqual("<add><doc boost=\"2.1\" /></add>", content);
                return EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml");
            };
            var docSerializer = new SolrDocumentSerializer<TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer());
            var headerParser = new MSolrHeaderResponseParser();
            headerParser.parse = headerParser.parse.Return(null);
            var ops = new SolrBasicServer<TestDocumentWithoutUniqueKey>(connection, null, docSerializer, null, headerParser, null, null, null);
            ops.AddWithBoost(new[] { new KeyValuePair<TestDocumentWithoutUniqueKey, double?>(new TestDocumentWithoutUniqueKey(), 2.1), }, null);

            Assert.AreEqual(1, connection.post.Calls);
        }
开发者ID:rivuc,项目名称:SolrNet-1,代码行数:16,代码来源:SolrOperationsTests.cs

示例11: AddWithParameters

 public void AddWithParameters() {
     var xml = EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml");
     var connection = new MSolrConnection();
     connection.post += (url, content) => {
         Assert.AreEqual("/update", url);
         Assert.AreEqual("<add commitWithin=\"4343\" overwrite=\"false\"><doc /></add>", content);
         return xml;
     };
     var docSerializer = new SolrDocumentSerializer<TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer());
     var headerParser = new MSolrHeaderResponseParser();
     headerParser.parse = headerParser.parse.Return(null);
     var ops = new SolrBasicServer<TestDocumentWithoutUniqueKey>(connection, null, docSerializer, null, headerParser, null, null, null);
     var parameters = new AddParameters { CommitWithin = 4343, Overwrite = false };
     ops.AddWithBoost(new[] { new KeyValuePair<TestDocumentWithoutUniqueKey, double?>(new TestDocumentWithoutUniqueKey(), null), }, parameters);
     Assert.AreEqual(1, connection.post.Calls);
 }
开发者ID:FilipVV,项目名称:SolrNet,代码行数:16,代码来源:SolrOperationsTests.cs

示例12: DeleteByQuery

		public void DeleteByQuery() {
            const string queryString = "someQuery";
		    var q = new SolrQuery(queryString);
            var xml = string.Format("<delete><query>{0}</query></delete>", queryString);

		    var conn = new Mocks.MSolrConnection();
		    conn.post = conn.post.Args("/update", xml);

		    var querySerializer = new Mocks.MSolrQuerySerializer();
		    querySerializer.serialize += _ => queryString;

            var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(null, q, querySerializer), null);
            cmd.Execute(conn);

            Assert.AreEqual(1, conn.post.Calls);
		}
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:16,代码来源:DeleteCommandTests.cs

示例13: Execute

 public void Execute() {
     var parameters = new ExtractParameters(null, "1", "text.doc");
     var conn = new MSolrConnection();
     conn.postStream += (url, b, stream, kvs) => {
         Assert.AreEqual("/update/extract", url);
         var p = new[] {
             KV.Create("literal.id", parameters.Id),
             KV.Create("resource.name", parameters.ResourceName),
         };
         Assert.AreElementsEqualIgnoringOrder(p, kvs);
         return "";
     };
     var cmd = new ExtractCommand(parameters);
     cmd.Execute(conn);
     Assert.AreEqual(1, conn.postStream.Calls);
 }
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:16,代码来源:ExtractCommandTests.cs

示例14: Execute

		public void Execute() {
		    var conn = new Mocks.MSolrConnection();
		    conn.post += (url, content) => {
		        Assert.AreEqual("/update", url);
		        Assert.AreEqual("<add><doc><field name=\"Id\">id</field><field name=\"Flower\">23.5</field></doc></add>", content);
		        Console.WriteLine(content);
		        return null;
		    };
		    var docSerializer = new SolrDocumentSerializer<SampleDoc>(new AttributesMappingManager(), new DefaultFieldSerializer());
            var docs = new[] {
                new KeyValuePair<SampleDoc, double?>(new SampleDoc(), null), 
			};
            var cmd = new AddCommand<SampleDoc>(docs, docSerializer, null);
            cmd.Execute(conn);
            Assert.AreEqual(1, conn.post.Calls);
        }
开发者ID:FilipVV,项目名称:SolrNet,代码行数:16,代码来源:AddCommandTests.cs

示例15: DeleteByIdAndQuery

        public void DeleteByIdAndQuery()
        {
            var ids = new[] { "123", "456" };
            const string queryString = "someQuery";
            var xml = string.Format("<delete><id>{0}</id><id>{1}</id><query>{2}</query></delete>", ids[0], ids[1], queryString);
            var conn = new Mocks.MSolrConnection();
            conn.post = conn.post.Args("/update", xml);

            var q = new SolrQuery(queryString);
            var querySerializer = new Mocks.MSolrQuerySerializer();
            querySerializer.serialize += _ => queryString;

            var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(ids, q, querySerializer));
            cmd.Execute(conn);

            Assert.AreEqual(1, conn.post.Calls);
        }
开发者ID:richtea,项目名称:SolrNet,代码行数:17,代码来源:DeleteCommandTests.cs


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