Skip to content

Commit

Permalink
DYN-6055 Lucene Search Category Based Code Review
Browse files Browse the repository at this point in the history
Adding a unit test that will validate category search based.
  • Loading branch information
RobertGlobant20 committed Dec 7, 2023
1 parent a3f7bd6 commit d38e79a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/DynamoCoreWpfTests/SearchSideEffects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,42 @@ public void LuceneSearchNodesByCategoryValidation()
}
}

/// <summary>
/// This test validates several cases using Search Category Based (like "category.node")
/// </summary>
[Test]
[Category("UnitTests")]
public void LuceneValidateCategoryBasedSearch()
{
Assert.IsAssignableFrom(typeof(HomeWorkspaceModel), ViewModel.Model.CurrentWorkspace);
string category = "FileSystem";
string nodeName = "F";
string searchTerm = category + "." + nodeName;

// Search and check that the results are correct based in the node name provided for the searchTerm
var nodesResult = ViewModel.CurrentSpaceViewModel.InCanvasSearchViewModel.Search(searchTerm);

//Take the first 5 elements in the results
var topFourResults = nodesResult.Take(5);
//Validate that the top 4 elements in the results start with "F"
Assert.That(topFourResults.Where(x => x.Name.StartsWith(nodeName)).Count() == 4, Is.True);
//Validate that the top 5 elements in the results belong to the FileSystem category
Assert.That(topFourResults.Where(x => x.Class.Equals(category)).Count() == 5);

nodeName = "Append";
searchTerm = category + "." + nodeName;
nodesResult = ViewModel.CurrentSpaceViewModel.InCanvasSearchViewModel.Search(searchTerm);
//Validate that the first in the node is AppendText
Assert.That(nodesResult.Take(1).First().Name.StartsWith(nodeName), Is.True);
//Validate that the first result belong to the FileSystem category
Assert.That(nodesResult.Take(1).First().Class == category, Is.True);

searchTerm = ".";
//This search should not return results since we are searching just for the "." char
nodesResult = ViewModel.CurrentSpaceViewModel.InCanvasSearchViewModel.Search(searchTerm);
Assert.That(nodesResult.Count() == 0, Is.True);
}

//This test will validate that resulting nodes have a specific order
[Test]
[Category("UnitTests")]
Expand Down

0 comments on commit d38e79a

Please sign in to comment.