public void CanConvertToPostPayload() { var parameters = new SuggestParameters() { Filter = "x eq y", HighlightPostTag = "</em>", HighlightPreTag = "<em>", MinimumCoverage = 33.3, OrderBy = new[] { "a", "b desc" }, SearchFields = new[] { "a", "b", "c" }, Select = new[] { "e", "f", "g" }, Top = 5, UseFuzzyMatching = true }; SuggestParametersPayload payload = parameters.ToPayload("find me", "mySuggester"); Assert.Equal(parameters.Filter, payload.Filter); Assert.Equal(parameters.HighlightPostTag, payload.HighlightPostTag); Assert.Equal(parameters.HighlightPreTag, payload.HighlightPreTag); Assert.Equal(parameters.MinimumCoverage, payload.MinimumCoverage); Assert.Equal(parameters.OrderBy.ToCommaSeparatedString(), payload.OrderBy); Assert.Equal("find me", payload.Search); Assert.Equal(parameters.SearchFields.ToCommaSeparatedString(), payload.SearchFields); Assert.Equal(parameters.Select.ToCommaSeparatedString(), payload.Select); Assert.Equal("mySuggester", payload.SuggesterName); Assert.Equal(parameters.Top, payload.Top); Assert.Equal(parameters.UseFuzzyMatching, payload.Fuzzy); }
public void MissingParametersAreMissingInThePayload() { var parameters = new SuggestParameters(); // Search text and suggester name can never be null. SuggestParametersPayload payload = parameters.ToPayload("find me", "mySuggester"); Assert.Null(payload.Filter); Assert.Null(payload.HighlightPostTag); Assert.Null(payload.HighlightPreTag); Assert.Null(payload.MinimumCoverage); Assert.Null(payload.OrderBy); Assert.Equal("find me", payload.Search); Assert.Null(payload.SearchFields); Assert.Equal("*", payload.Select); // Nothing selected for Suggest means select everything. Assert.Equal("mySuggester", payload.SuggesterName); Assert.Null(payload.Top); Assert.True(payload.Fuzzy.HasValue); Assert.False(payload.Fuzzy.Value); // Fuzzy is non-nullable in the client-side contract. }