Esempio n. 1
0
 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);
 }
Esempio n. 2
0
        public void Execute()
        {
            var mocks = new MockRepository();
            var conn = mocks.StrictMock<ISolrConnection>();
            var parameters = new ExtractParameters(null, "1", "text.doc");

            With.Mocks(mocks).Expecting(() => {
                Expect.Call(conn.PostStream("/update/extract", null, null, new List<KeyValuePair<string, string>> {
                    KV.Create("literal.id", parameters.Id),
                    KV.Create("resource.name", parameters.ResourceName),
                }))
                .Repeat.Once()
                .Return("");
            })
            .Verify(() => {
                var cmd = new ExtractCommand(new ExtractParameters(null, "1", "text.doc"));
                cmd.Execute(conn);
            });
        }
Esempio n. 3
0
 public void ExecuteWithDuplicateIdField() {
     const string DuplicateId = "duplicateId";
     var cmd = new ExtractCommand(new ExtractParameters(null, DuplicateId, "text.doc") {
         Fields = new[] {
             new ExtractField("id", DuplicateId),
             new ExtractField("field2", "value2"),
         }
     });
     cmd.Execute(null);
 }
Esempio n. 4
0
        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")
                };

                Assert.AreElementsEqualIgnoringOrder(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);
        }
Esempio n. 5
0
        public void ExecuteWithAllParameters()
        {
            var mocks = new MockRepository();
            var conn = mocks.StrictMock<ISolrConnection>();
            var parameters = new ExtractParameters(null, "1", "text.doc");

            With.Mocks(mocks).Expecting(() =>
            {
                Expect.Call(conn.PostStream("/update/extract", "application/word-document", null, new List<KeyValuePair<string, string>> {
                    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")
                }))
                .Repeat.Once()
                .Return("");
            })
            .Verify(() =>
            {
                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);
            });
        }
Esempio n. 6
0
        public void ExecuteWithDuplicateIdField()
        {
            var mocks = new MockRepository();
            var conn = mocks.StrictMock<ISolrConnection>();

            const string DuplicateId = "duplicateId";
            var cmd = new ExtractCommand(new ExtractParameters(null, DuplicateId, "text.doc")
            {
                Fields = new[] { new ExtractField("id", DuplicateId), new ExtractField("field2", "value2") }
            });
            cmd.Execute(conn);
        }