public void Search_nullPassedToFind_EmptyListReturned() { //1 var ls = new StudentWorksSearch.LuceneSearch.LuceneEngine(); int inList; //2 var returned = ls.Search(null, out inList); //3 Assert.AreEqual(0, returned.Count <FileToIndex>()); }
public void BuildIndex_nullHashtags_NullReferenceException() { var ls = new StudentWorksSearch.LuceneSearch.LuceneEngine(); ls.BuildIndex(new FileToIndex { Id = 0, Authors = "test", Description = "test", Hashtags = null, Text = "test", Title = "test", Discipline = "test" }); }
public void BuildIndex_nullTitle_NullReferenceException() { var ls = new StudentWorksSearch.LuceneSearch.LuceneEngine(); ls.BuildIndex(new FileToIndex { Id = 0, Authors = "test", Description = "test", Hashtags = "test", Text = "test", Title = null, Discipline = "test" }); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { try { LuceneSearch.LuceneEngine le = new LuceneSearch.LuceneEngine(); var engine = new FileEngine(); if (txtboxName.Text != "" && cmbboxDis.SelectedIndex != -1 && btnFile.Content.ToString() != "Выбрать файл") { var IndexMe= engine.AddFile(txtboxName.Text, cmbboxDis.SelectedIndex, txtboxAuth.Text, txtboxTags.Text, txtboxComment.Text); le.BuildIndex(IndexMe);//index this file this.Close(); } else MessageBox.Show("Вы ввели не все данные!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void BuildIndex_objectPassed_NumberOfDocsIncreased() { //1 var ls = new StudentWorksSearch.LuceneSearch.LuceneEngine(); var file = new FileToIndex { Id = 0, Authors = "test", Description = "test", Hashtags = "test", Text = "test", Title = null, Discipline = "test" }; var was = ls.CountDocs(); //2 ls.BuildIndex(file); var now = ls.CountDocs(); //3 Assert.AreEqual(was + 1, now); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { try { LuceneSearch.LuceneEngine le = new LuceneSearch.LuceneEngine(); var engine = new FileEngine(); if (txtboxName.Text != "" && cmbboxDis.SelectedIndex != -1 && btnFile.Content.ToString() != "Выбрать файл") { var IndexMe = engine.AddFile(txtboxName.Text, cmbboxDis.SelectedIndex, txtboxAuth.Text, txtboxTags.Text, txtboxComment.Text); le.BuildIndex(IndexMe);//index this file this.Close(); } else { MessageBox.Show("Вы ввели не все данные!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void BuildIndex_nullObject_NullReferenceException() { var ls = new StudentWorksSearch.LuceneSearch.LuceneEngine(); ls.BuildIndex(new StudentWorksSearch.LuceneSearch.FileToIndex()); }
public void Search_nullPassedToFind_EmptyListReturned() { //1 var ls = new StudentWorksSearch.LuceneSearch.LuceneEngine(); int inList; //2 var returned= ls.Search(null, out inList); //3 Assert.AreEqual(0, returned.Count<FileToIndex>()); }
public void BuildIndex_objectPassed_NumberOfDocsIncreased() { //1 var ls = new StudentWorksSearch.LuceneSearch.LuceneEngine(); var file= new FileToIndex { Id = 0, Authors = "test", Description = "test", Hashtags = "test", Text = "test", Title = null, Discipline = "test" }; var was = ls.CountDocs(); //2 ls.BuildIndex(file); var now = ls.CountDocs(); //3 Assert.AreEqual(was+1,now); }
public void BuildIndex_nullObject_NullReferenceException() { var ls = new StudentWorksSearch.LuceneSearch.LuceneEngine(); ls.BuildIndex(new StudentWorksSearch.LuceneSearch.FileToIndex()); }
//без статик // все что понадобится и может быть связано с папкой lucene private void btnSearch_Click(object sender, RoutedEventArgs e) { btnPlagCheck.IsEnabled = false; DownloadWork.IsEnabled = false; var engine = new DBEngine(); try { if (engine.CheckWorks()) { txtAuth.Text = ""; txtDis.Text = ""; txtName.Text = ""; txtDes.Text = ""; LuceneEngine le = new LuceneEngine(); //var c = le.CountDocs(); int number;//количество результатов string field = ""; IEnumerable<FileToIndex> results; if (txtboxSearch.Text.StartsWith("#")) { field = "Hashtags"; results = le.Search(txtboxSearch.Text.Substring(1, txtboxSearch.Text.Length - 1), out number, field); } else { results = le.Search(txtboxSearch.Text, out number); } lstboxResult.Items.Clear(); foreach (var doc in results) { lstboxResult.Items.Add(doc.Id + " " + doc.Title); } } } catch (Exception ex) { MessageBox.Show("Поиск не может быть проведен.\n" + ex,"Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }