public void TestSizeForTwoSuggestions(string suggestion1, SuggestionSource source1, string suggestion2, SuggestionSource source2, bool isCancelled, string userInput) { // The text in the telemetry data is like // { "Found":[["Get-AzSubscription",3],["Get-AzSecurityPricing -DefaultProfile <IAzureContextContainer>",1]],"IsCanclled":"False","UserInput":"ge" } var commandLineSuggestion = new CommandLineSuggestion(); commandLineSuggestion.AddSuggestion(new PredictiveSuggestion(suggestion1, null), suggestion1, source1); commandLineSuggestion.AddSuggestion(new PredictiveSuggestion(suggestion2, null), suggestion2, source2); var suggestionSession = new SuggestionSession() { FoundSuggestion = commandLineSuggestion, IsCancellationRequested = isCancelled, UserInput = userInput, IsSuggestionComplete = true, }; var expectedSize = GetSuggestionTelemetryData.PropertyNameFound.Length + SuggestionSessionTests._AdditionalSizeForKey + suggestion1.Length + SuggestionSessionTests._AdditionalSizeForString + 1 // For the one digit of source1 + SuggestionSessionTests._AdditionalSizeForTwoElementArray // for [,] + suggestion2.Length + SuggestionSessionTests._AdditionalSizeForString + 1 // for the one digit of source2 + SuggestionSessionTests._AdditionalSizeForTwoElementArray // for [,] + SuggestionSessionTests._AdditionalSizeForTwoElementArray // for [,] in Found + GetSuggestionTelemetryData.PropertyNameUserInput.Length + SuggestionSessionTests._AdditionalSizeForKey + userInput.Length + SuggestionSessionTests._AdditionalSizeForString + GetSuggestionTelemetryData.PropertyNameIsCancelled.Length + SuggestionSessionTests._AdditionalSizeForKey + isCancelled.ToString(CultureInfo.InvariantCulture).Length; Assert.Equal(expectedSize, suggestionSession.EstimateTelemetrySize); }
public void TestSizeForAcceptSuggestion(string suggestion, SuggestionSource source, bool isCancelled, string userInput, string acceptedSuggestion) { // The text in the telemetry data is like // { "Found":[["Get-AzSubscription",3]],"IsCanclled":"False","UserInput":"ge","Accepted":"Get-AzSubscription" } var commandLineSuggestion = new CommandLineSuggestion(); commandLineSuggestion.AddSuggestion(new PredictiveSuggestion(suggestion, null), suggestion, source); var suggestionSession = new SuggestionSession() { FoundSuggestion = commandLineSuggestion, IsCancellationRequested = isCancelled, UserInput = userInput, AcceptedSuggestion = acceptedSuggestion, IsSuggestionComplete = true, }; var expectedSize = GetSuggestionTelemetryData.PropertyNameFound.Length + SuggestionSessionTests._AdditionalSizeForKey + suggestion.Length + SuggestionSessionTests._AdditionalSizeForString + 1 // For the one digit of source + SuggestionSessionTests._AdditionalSizeForTwoElementArray // for [,] + SuggestionSessionTests._AdditionalSizeForArrayBracket // for [] in Found + GetSuggestionTelemetryData.PropertyNameUserInput.Length + SuggestionSessionTests._AdditionalSizeForKey + userInput.Length + SuggestionSessionTests._AdditionalSizeForString + GetSuggestionTelemetryData.PropertyNameIsCancelled.Length + SuggestionSessionTests._AdditionalSizeForKey + isCancelled.ToString(CultureInfo.InvariantCulture).Length + SuggestionAcceptedTelemetryData.PropertyNameAccepted.Length + SuggestionSessionTests._AdditionalSizeForKey + acceptedSuggestion.Length + SuggestionSessionTests._AdditionalSizeForString; Assert.Equal(expectedSize, suggestionSession.EstimateTelemetrySize); }