예제 #1
0
        public void AddWithParameters()
        {
            var mocks         = new MockRepository();
            var connection    = mocks.StrictMock <ISolrConnection>();
            var executer      = mocks.StrictMock <ISolrQueryExecuter <TestDocumentWithoutUniqueKey> >();
            var headerParser  = mocks.StrictMock <ISolrHeaderResponseParser>();
            var docSerializer = new SolrDocumentSerializer <TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer());

            With.Mocks(mocks)
            .Expecting(() => {
                Expect.On(connection)
                .Call(connection.Post("/update", "<add commitWithin=\"4343\" overwrite=\"false\"><doc /></add>"))
                .Repeat.Once()
                .Return(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml"));
                Expect.On(headerParser)
                .Call(headerParser.Parse(null))
                .IgnoreArguments()
                .Return(new ResponseHeader());
            })
            .Verify(() => {
                var ops        = new SolrBasicServer <TestDocumentWithoutUniqueKey>(connection, executer, 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);
            });
        }
예제 #2
0
 public void Add()
 {
     var mocks = new MockRepository();
     var connection = mocks.StrictMock<ISolrConnection>();
     var executer = mocks.StrictMock<ISolrQueryExecuter<TestDocumentWithoutUniqueKey>>();
     var headerParser = mocks.StrictMock<ISolrHeaderResponseParser>();
     var docSerializer = new SolrDocumentSerializer<TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer());
     With.Mocks(mocks)
         .Expecting(() => {
             Expect.On(connection)
                 .Call(connection.Post("/update", "<add><doc /></add>"))
                 .Repeat.Once()
                 .Return(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml"));
             Expect.On(headerParser)
                 .Call(headerParser.Parse(null))
                 .IgnoreArguments()
                 .Return(new ResponseHeader());
         })
         .Verify(() => {
             var ops = new SolrBasicServer<TestDocumentWithoutUniqueKey>(connection, executer, docSerializer, null, headerParser, null, null, null);
             ops.AddWithBoost(new[] {
                 new KeyValuePair<TestDocumentWithoutUniqueKey, double?>(new TestDocumentWithoutUniqueKey(), null),
             }, null);
         });
 }
예제 #3
0
 public void AddWithBoost()
 {
     var mocks = new MockRepository();
     var connection = mocks.CreateMock<ISolrConnection>();
     var executer = mocks.CreateMock<ISolrQueryExecuter<TestDocumentWithoutUniqueKey>>();
     var docSerializer = new SolrDocumentSerializer<TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer());
     With.Mocks(mocks)
         .Expecting(() => Expect.Call(connection.Post("/update", "<add><doc boost=\"2.1\" /></add>"))
                              .Repeat.Once()
                              .Return(null))
         .Verify(() => {
             var ops = new SolrBasicServer<TestDocumentWithoutUniqueKey>(connection, executer, docSerializer);
             ops.AddWithBoost(new[] {new KeyValuePair<TestDocumentWithoutUniqueKey, double?>(new TestDocumentWithoutUniqueKey(), 2.1),});
         });
 }
예제 #4
0
        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);
        }
예제 #5
0
 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);
 }
예제 #6
0
        public void Add() {
            var xml = EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml");
            var connection = new MSolrConnection();
            connection.post = connection.post
                .Expect(1)
                .Args("/update", "<add><doc /></add>")
                .Return(xml);

            var headerParser = new MSolrHeaderResponseParser();
            headerParser.parse = headerParser.parse.Return(null);

            var docSerializer = new SolrDocumentSerializer<TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer());
            var ops = new SolrBasicServer<TestDocumentWithoutUniqueKey>(connection, null, docSerializer, null, headerParser, null, null, null);
            ops.AddWithBoost(new[] {
                new KeyValuePair<TestDocumentWithoutUniqueKey, double?>(new TestDocumentWithoutUniqueKey(), null),
            }, null);
            connection.post.Verify();
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        public void Add()
        {
            var xml        = EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml");
            var connection = new MSolrConnection();

            connection.post = connection.post
                              .Expect(1)
                              .Args("/update", "<add><doc /></add>")
                              .Return(xml);

            var headerParser = new MSolrHeaderResponseParser();

            headerParser.parse = headerParser.parse.Return(null);

            var docSerializer = new SolrDocumentSerializer <TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer());
            var ops           = new SolrBasicServer <TestDocumentWithoutUniqueKey>(connection, null, docSerializer, null, headerParser, null, null, null);

            ops.AddWithBoost(new[] {
                new KeyValuePair <TestDocumentWithoutUniqueKey, double?>(new TestDocumentWithoutUniqueKey(), null),
            }, null);
            connection.post.Verify();
        }