本文整理汇总了C#中SolrBasicServer.Extract方法的典型用法代码示例。如果您正苦于以下问题:C# SolrBasicServer.Extract方法的具体用法?C# SolrBasicServer.Extract怎么用?C# SolrBasicServer.Extract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SolrBasicServer
的用法示例。
在下文中一共展示了SolrBasicServer.Extract方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Extract
public void Extract()
{
var mocks = new MockRepository();
var connection = mocks.StrictMock<ISolrConnection>();
var executer = mocks.StrictMock<ISolrQueryExecuter<TestDocumentWithoutUniqueKey>>();
var headerParser = mocks.StrictMock<ISolrHeaderResponseParser>();
var extractResponseParser = mocks.StrictMock<ISolrExtractResponseParser>();
var docSerializer = new SolrDocumentSerializer<TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer());
var parameters = new ExtractParameters(null, "1", "test.doc");
With.Mocks(mocks)
.Expecting(() => {
Expect.On(connection)
.Call(connection.PostStream("/update/extract", null, parameters.Content, new List<KeyValuePair<string, string>> {
new KeyValuePair<string, string>("literal.id", parameters.Id),
new KeyValuePair<string, string>("resource.name", parameters.ResourceName),
}))
.Repeat.Once()
.Return(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.responseWithExtractContent.xml"));
Expect.On(extractResponseParser)
.Call(extractResponseParser.Parse(null))
.IgnoreArguments()
.Return(new ExtractResponse(null));
})
.Verify(() => {
var ops = new SolrBasicServer<TestDocumentWithoutUniqueKey>(connection, executer, docSerializer, null, headerParser, null, null, extractResponseParser);
ops.Extract(parameters);
});
}
示例2: Extract
public void Extract()
{
var parameters = new ExtractParameters(null, "1", "test.doc");
var connection = new MSolrConnection();
connection.postStream += (url, contentType, content, param) => {
Assert.AreEqual("/update/extract", url);
Assert.AreEqual(parameters.Content, content);
var expectedParams = new[] {
KV.Create("literal.id", parameters.Id),
KV.Create("resource.name", parameters.ResourceName),
};
Assert.AreElementsEqualIgnoringOrder(expectedParams, param);
return EmbeddedResource.GetEmbeddedString(GetType(), "Resources.responseWithExtractContent.xml");
};
var docSerializer = new SolrDocumentSerializer<TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer());
var extractResponseParser = new MSolrExtractResponseParser {
parse = _ => new ExtractResponse(null)
};
var ops = new SolrBasicServer<TestDocumentWithoutUniqueKey>(connection, null, docSerializer, null, null, null, null, extractResponseParser);
ops.Extract(parameters);
Assert.AreEqual(1, connection.postStream.Calls);
}