public void VerifySuggestionOnIncompleteCommand() { // We need to get the suggestions for more than one and the cohort from the context. So we create a local version az predictor and the service. var startHistory = $"{AzPredictorConstants.CommandPlaceholder}{AzPredictorConstants.CommandConcatenator}{AzPredictorConstants.CommandPlaceholder}"; var azContext = new MockAzContext() { Cohort = 0, }; var localPredictorService = new MockAzPredictorService(startHistory, _fixture.PredictionCollection[startHistory], _fixture.CommandCollection, azContext); using var localAzPredictor = new AzPredictor(localPredictorService, _telemetryClient, new Settings() { SuggestionCount = 7, MaxAllowedCommandDuplicate = 1, }, azContext); var userInput = "New-AzResourceGroup -Name 'ResourceGroup01' -Location 'Central US' -WhatIf -"; var expected = "New-AzResourceGroup -Name 'ResourceGroup01' -Location 'Central US' -WhatIf -Tag value1"; var predictionContext = PredictionContext.Create(userInput); var actual = localAzPredictor.GetSuggestion(MockObjects.PredictionClient, predictionContext, CancellationToken.None); Assert.Equal(expected, actual.SuggestionEntries.First().SuggestionText); }
/// <inhertdoc /> public void Dispose() { if (_azPredictor != null) { _azPredictor.Dispose(); _azPredictor = null; } }
/// <summary> /// Constructs a new instance of <see cref="AzPredictorTests"/> /// </summary> public AzPredictorTests(ModelFixture modelFixture) { this._fixture = modelFixture; var startHistory = $"{AzPredictorConstants.CommandPlaceholder}{AzPredictorConstants.CommandConcatenator}{AzPredictorConstants.CommandPlaceholder}"; this._service = new MockAzPredictorService(startHistory, this._fixture.PredictionCollection[startHistory], this._fixture.CommandCollection); this._telemetryClient = new MockAzPredictorTelemetryClient(); this._azPredictor = new AzPredictor(this._service, this._telemetryClient, new Settings() { SuggestionCount = 1, }, null); }
/// <summary> /// Constructs a new instance of <see cref="AzPredictorTests"/> /// </summary> public AzPredictorTests(ModelFixture modelFixture) { _fixture = modelFixture; var startHistory = $"{AzPredictorConstants.CommandPlaceholder}{AzPredictorConstants.CommandConcatenator}{AzPredictorConstants.CommandPlaceholder}"; _service = new MockAzPredictorService(startHistory, _fixture.PredictionCollection[startHistory], _fixture.CommandCollection, null); _telemetryClient = new MockAzPredictorTelemetryClient(); _azPredictor = new AzPredictor(_service, _telemetryClient, new Settings() { SuggestionCount = 1, MaxAllowedCommandDuplicate = 1, }, null); }
public void VerifySuggestionOnIncompleteCommand() { // We need to get the suggestions for more than one. So we create a local version az predictor. var localAzPredictor = new AzPredictor(this._service, this._telemetryClient, new Settings() { SuggestionCount = 7, }, null); var userInput = "New-AzResourceGroup -Name 'ResourceGroup01' -Location 'Central US' -WhatIf -"; var expected = "New-AzResourceGroup -Name 'ResourceGroup01' -Location 'Central US' -WhatIf -Verbose ***"; var predictionContext = PredictionContext.Create(userInput); var actual = localAzPredictor.GetSuggestion(predictionContext, CancellationToken.None); Assert.Equal(expected, actual.First().SuggestionText); }
public void VerifySuggestionOnIncompleteCommand() { // We need to get the suggestions for more than one. So we create a local version az predictor. using var localAzPredictor = new AzPredictor(_service, _telemetryClient, new Settings() { SuggestionCount = 7, MaxAllowedCommandDuplicate = 1, }, null); var userInput = "New-AzResourceGroup -Name 'ResourceGroup01' -Location 'Central US' -WhatIf -"; var expected = "New-AzResourceGroup -Name 'ResourceGroup01' -Location 'Central US' -WhatIf -Tag value1"; var predictionContext = PredictionContext.Create(userInput); var actual = localAzPredictor.GetSuggestion(MockObjects.PredictionClient, predictionContext, CancellationToken.None); Assert.Equal(expected, actual.SuggestionEntries.First().SuggestionText); }
private (AzPredictor, MockAzPredictorTelemetryClient) CreateTestObjects(bool throwException, int expectedTelemetryEvent) { var telemetryClient = new MockAzPredictorTelemetryClient(); telemetryClient.ResetWaitingTasks(); telemetryClient.ExceptedTelemetryRecordCount = expectedTelemetryEvent; var startHistory = $"{AzPredictorConstants.CommandPlaceholder}{AzPredictorConstants.CommandConcatenator}{AzPredictorConstants.CommandPlaceholder}"; var service = new MockAzPredictorService(startHistory, _fixture.PredictionCollection[startHistory], _fixture.CommandCollection); service.ThrowException = throwException; var azPredictor = new AzPredictor(service, telemetryClient, new Settings() { SuggestionCount = 1, MaxAllowedCommandDuplicate = 1, }, null); return(azPredictor, telemetryClient); }