public void SearchPropertyNameUtility_OrderBy() { ISuggestParametersBuilder <Model> suggestParametersBuilder = SuggestParametersBuilder <Model> .Create(); Assert.IsNull(suggestParametersBuilder.OrderBy); suggestParametersBuilder.WithOrderBy(_ => Constants.SearchScore).WithThenByDescending(_ => Constants.SearchScore); Assert.IsNotNull(suggestParametersBuilder.OrderBy); Assert.AreEqual(2, suggestParametersBuilder.OrderBy.Count()); Assert.AreEqual("search.score() asc", suggestParametersBuilder.OrderBy.ElementAtOrDefault(0)); Assert.AreEqual("search.score() desc", suggestParametersBuilder.OrderBy.ElementAtOrDefault(1)); SuggestParameters parameters = suggestParametersBuilder.Build(); Assert.IsNotNull(parameters); Assert.IsNotNull(parameters.OrderBy); Assert.AreEqual(2, parameters.OrderBy.Count()); Assert.AreEqual("search.score() asc", parameters.OrderBy.ElementAtOrDefault(0)); Assert.AreEqual("search.score() desc", parameters.OrderBy.ElementAtOrDefault(1)); suggestParametersBuilder.WithOrderByDescending(_ => Constants.SearchScore).WithThenBy(_ => Constants.SearchScore); Assert.IsNotNull(suggestParametersBuilder.OrderBy); Assert.AreEqual(2, suggestParametersBuilder.OrderBy.Count()); Assert.AreEqual("search.score() desc", suggestParametersBuilder.OrderBy.ElementAtOrDefault(0)); Assert.AreEqual("search.score() asc", suggestParametersBuilder.OrderBy.ElementAtOrDefault(1)); parameters = suggestParametersBuilder.Build(); Assert.IsNotNull(parameters); Assert.IsNotNull(parameters.OrderBy); Assert.AreEqual(2, parameters.OrderBy.Count()); Assert.AreEqual("search.score() desc", parameters.OrderBy.ElementAtOrDefault(0)); Assert.AreEqual("search.score() asc", parameters.OrderBy.ElementAtOrDefault(1)); }
public void SuggestPropertyNameUtility_UseFuzzyMatching() { ISuggestParametersBuilder <Model> suggestParametersBuilder = SuggestParametersBuilder <Model> .Create(); Assert.IsFalse(suggestParametersBuilder.UseFuzzyMatching); suggestParametersBuilder.WithUseFuzzyMatching(true); Assert.IsNotNull(suggestParametersBuilder.UseFuzzyMatching); Assert.IsTrue(suggestParametersBuilder.UseFuzzyMatching); SuggestParameters parameters = suggestParametersBuilder.Build(); Assert.IsNotNull(parameters); Assert.IsTrue(parameters.UseFuzzyMatching); }
public void SearchPropertyNameUtility_Select() { ISuggestParametersBuilder <Model> suggestParametersBuilder = SuggestParametersBuilder <Model> .Create(); Assert.IsNull(suggestParametersBuilder.Select); suggestParametersBuilder.WithSelect(_ => Constants.SearchScore); Assert.IsNotNull(suggestParametersBuilder.Select); Assert.AreEqual(1, suggestParametersBuilder.Select.Count()); Assert.AreEqual("search.score()", suggestParametersBuilder.Select.ElementAtOrDefault(0)); SuggestParameters parameters = suggestParametersBuilder.Build(); Assert.IsNotNull(parameters); Assert.IsNotNull(parameters.Select); Assert.AreEqual(1, parameters.Select.Count()); Assert.AreEqual("search.score()", parameters.Select.ElementAtOrDefault(0)); }