November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi
You should be able to do something like this (I'm using Moq, but it basically the same):
Does this help you?
SearchResult<SearchResultItem> searchResult = new SearchResult<SearchResultItem>
{
Hits = new HitCollection<SearchResultItem>
{
Hits = new EditableList<SearchHit<SearchResultItem>>
{
new SearchHit<SearchResultItem>
{
Document = new SearchResultItem
{
LinkUrl = "Url1"
}
},
new SearchHit<SearchResultItem>
{
Document = new SearchResultItem
{
LinkUrl = "Url2"
}
}
},
}
};
SearchResults<SearchResultItem> result = new SearchResults<SearchResultItem>(searchResult);
_resultFacade.Setup(x => x.GetResult(It.IsAny<ISearch<SearchResultItem>>())).Returns(result);
That is really helpful thanks. A translation into Rhino Mocks still doesn't work sadly. The problem is that I am calling GetContentResults since we are returning pages. This changes the code so that it needs ContentInLanguageReference so it becomes
//..generating mock results
var mockResults = MockRepository.GenerateMock<IContentResult<ProductPage>>();
SearchResult<ContentInLanguageReference> searchResult = new SearchResult<ContentInLanguageReference>
{
Hits = new HitCollection<ContentInLanguageReference>
{
Hits = new List<SearchHit<ContentInLanguageReference>>
{
new SearchHit<ContentInLanguageReference>
{
Document = new ContentInLanguageReference(new ProductPage { ProductName = "Product 1" })
},
new SearchHit<ContentInLanguageReference>
{
Document = new ContentInLanguageReference(new ProductPage { ProductName = "Product 2" })
}
}
}
};
SearchResults<ContentInLanguageReference> result = new SearchResults<ContentInLanguageReference>(searchResult);
mockResults.Stub(x => x.SearchResult).Return(result);
But running this through gives a object null error. The failure is instantiating ContentInLanguageReference i,e,
var result = new ContentInLanguageReference(new ProductPage { ProductName = "Product 1" })
Would error.
Anyone any ideas about how to get this instantiated?
Many Thanks
We have med the class SearchResultItem our self.
We are searching something like this:
ITypeSearch<IBasePageData> searchQuery = _client.Instance()
.Search<IBasePageData>(Language.Norwegian)
.For(searchParameters.Query)
.Take(100);
List<SearchResultItem> searchHits = new List<SearchResultItem>();
ISearch<SearchResultItem> resultQuery = searchQuery.Select(x => new SearchResultItem
{
Heading = x.Heading,
MainIntro = x.GetPreviewTextString,
MainBody = x.MainBody,
LinkUrl = x.PreviewLinkUrl
});
SearchResults<SearchResultItem> results = _resultFacade.GetResult(resultQuery);
But I guess you are using the EPi7 version of Find, so that may be a little different from our Cms6 version.
Hi
I'm trying to mock IContentResult with Rhino mocks but i'm a bit lost. Basically I want a set of content results with maybe 15 objects to test some paging. So far I've got
This hasn't done me any good. TotalMatching is still zero. Underlying this is SearchResults but trying to stub this out is confusing me.
Does anyone have any advice or tips.
Many Thanks