public void FilterSearchTest() { //Arrange setUp(); //Act var u = new SearchService(); SearchResultPTO result1 = u.FilterSearch("kyle", 1, 10, true); SearchResultPTO result2 = u.FilterSearch("d", 1, 10, true, 0, null, "foobar"); SearchResultPTO result3 = u.FilterSearch("", 1, 10, false, 0, null, "foobar"); SearchResultPTO result4 = u.FilterSearch("", 1, 10, false, 0, null, null, "bar"); SearchResultPTO result5 = u.FilterSearch("", 1, 10, false, 0, null, null, "foo"); //Assert Assert.AreEqual(result1.Results.Count(), 2); Assert.AreEqual(result1.Total, 2); Assert.AreEqual(result2.Results.Count(), 1); Assert.AreEqual(result2.Total, 1); Assert.AreEqual(result3.Results.Count(), 2); Assert.AreEqual(result3.Total, 2); Assert.AreEqual(result4.Results.Count(), 2); Assert.AreEqual(result4.Total, 2); Assert.AreEqual(result5.Results.Count(), 0); Assert.AreEqual(result5.Total, 0); }
public void GetDocumentsMissingMetadataTest() { //Arrange setUp(); //Act var a = new ReportService(); SearchResultPTO result = a.GetDocumentsMissingMetadata(); //Assert Assert.AreEqual(result.Results.Count(), 4); Assert.AreEqual(result.Total, 4); }
public void FullTextSearchTest() { //Arrange setUp(); //Act var u = new SearchService(); var Repository = new DocuRepository(MockContext); SearchResultPTO result1 = u.FullTextSearch("kyle"); SearchResultPTO result2 = u.FullTextSearch("robbie"); //Assert Assert.AreEqual(result1.Results.Count(), 3); Assert.AreEqual(result1.Total, 3); Assert.IsNotNull(Repository.GetDocumentByID(result1.Results.First().DocumentID)); Assert.AreEqual(result2.Results.Count(), 0); Assert.AreEqual(result2.Total, 0); }
public SearchResultPTO GetDocumentsMissingMetadata() { using (var dc = new DocuContext()) { var final = new SearchResultPTO(); var missingMetadata = dc.Documents.Where(m => String.IsNullOrEmpty(m.DocuType) || String.IsNullOrEmpty(m.SubType) || String.IsNullOrEmpty(m.FunctionalArea) || String.IsNullOrEmpty(m.Release)); final.Total = missingMetadata.Count(); final.Results = missingMetadata.Take(10).Select(r => new ResultPTO { DocumentID = r.DocumentID, DocuID = r.DocuID, DocuType = r.DocuType, FilePath = r.FilePath.FileName, FileSize = r.FileSize, FunctionalArea = r.FunctionalArea, LastModified = r.LastModified, Release = r.Release, Subtitle = r.Subtitle, SubType = r.SubType, Title = r.Title }).ToList(); return(final); } }