Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the data in the test cases #18496

Merged
merged 2 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</ItemGroup>

<ItemGroup>
<None Include="Data\CommandsModel.zip" CopyToOutputDirectory="PreserveNewest" />
<None Include="Data\PredictionsModel.zip" CopyToOutputDirectory="PreserveNewest" />
<None Include="Data\CommandsModel.json" CopyToOutputDirectory="PreserveNewest" />
<None Include="Data\PredictionsModel.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void Dispose()
[Fact]
public void VerifyParameterValues()
{
var predictionContext = PredictionContext.Create("Get-AzContext");
var predictionContext = PredictionContext.Create("Set-Content");

Action actual = () => this._service.GetSuggestion(null, 1, 1, CancellationToken.None);
Assert.Throws<ArgumentNullException>(actual);
Expand All @@ -116,14 +116,14 @@ public void VerifyParameterValues()
/// Verifies that the prediction comes from the command based list, not the fallback list.
/// </summary>
[Theory]
[InlineData("CONNECT-AZACCOUNT")]
[InlineData("set-azstorageaccount ")]
[InlineData("Get-AzResourceG")]
[InlineData("Get-AzStorageAcco")]
[InlineData("Get-AzKeyVault -VaultName")]
[InlineData("GET-AZSTORAGEACCOUNTKEY -NAME ")]
[InlineData("new-azresourcegroup -name hello")]
[InlineData("new-azresourcegroup hello")]
[InlineData("SET-CONTENT")]
[InlineData("get-logproperties ")]
[InlineData("Clear-C")]
[InlineData("compare-")]
[InlineData("Clear-Variable -Name")]
[InlineData("CLEAR-CONTENT -PATH test")]
[InlineData("Clear-content -path test")]
[InlineData("clear-content ./Test.log")]
public void VerifyUsingCommandBasedPredictor(string userInput)
{
var predictionContext = PredictionContext.Create(userInput);
Expand Down Expand Up @@ -165,8 +165,8 @@ public void VerifyUsingCommandBasedPredictor(string userInput)
/// Verifies that when no prediction is in the command based list, we'll use the fallback list.
/// </summary>
[Theory]
[InlineData("New-AzApiManagementContext -ResourceGroupName hello -Serv")]
[InlineData("Get-AzAlert -TimeRange '1h' -Incl")]
[InlineData("Set-Variable -Name desc -Value ")]
[InlineData("remove-ite")]
public void VerifyUsingFallbackPredictor(string userInput)
{
var predictionContext = PredictionContext.Create(userInput);
Expand Down Expand Up @@ -209,12 +209,13 @@ public void VerifyUsingFallbackPredictor(string userInput)
/// </summary>
[Theory]
[InlineData(AzPredictorConstants.CommandPlaceholder)]
[InlineData("Get-Help")]
[InlineData("Get-ChildItem")]
[InlineData("new-azresourcegroup -NoExistingParam")]
[InlineData("get-azaccount ")]
[InlineData("NEW-AZCONTEXT")]
[InlineData("Remove-Item -NoExistingParam")]
[InlineData("get-childitem ")]
[InlineData("NEW-CHILDITEM ")]
[InlineData("git status")]
[InlineData("Get-AzContext Name")]
[InlineData("get-item name")]
public void VerifyNoPrediction(string userInput)
{
var predictionContext = PredictionContext.Create(userInput);
Expand All @@ -235,7 +236,7 @@ public void VerifyNoPrediction(string userInput)
/// Verify that it returns null when we cannot parse the user input.
/// </summary>
[Theory]
[InlineData("New-AzVM -Name A $Location")]
[InlineData("Remove-Item -Name A $Location")]
public void VerifyFailToParseUserInput(string userInput)
{
var predictionContext = PredictionContext.Create(userInput);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public async Task VerifyRequestPredictionForOneSupportedCommandInHistory()
{
IReadOnlyList<string> history = new List<string>()
{
"New-AzVM -Name hello -Location WestUS"
"Get-LogProperties -Name:'Windows PowerShell'"
};

_service.Commands = null;
Expand All @@ -102,7 +102,7 @@ public async Task VerifyRequestPredictionForOneSupportedCommandInHistory()
_azPredictor.OnCommandLineAccepted(MockObjects.PredictionClient, history);
await _service.RequestPredictionTaskCompletionSource.Task;

string maskedCommand = "New-AzVM -Location *** -Name ***";
string maskedCommand = "Get-LogProperties -Name:***";

Assert.Equal(new List<string>() { AzPredictorConstants.CommandPlaceholder, maskedCommand }, _service.Commands);
Assert.Equal(history[0], _service.History.ToString());
Expand All @@ -116,8 +116,8 @@ public async Task VerifyRequestPredictionForTwoSupportedCommandInHistory()
{
IReadOnlyList<string> history = new List<string>()
{
"New-AzResourceGroup -Name 'resourceGroup01'",
"New-AzVM -Name:hello -Location:WestUS"
"Set-Content -Path C:\\Temp\\* -Filter *.txt -Value 'Empty'",
"Get-LogProperties -Name:'Windows PowerShell'"
};

_service.Commands = null;
Expand All @@ -129,8 +129,8 @@ public async Task VerifyRequestPredictionForTwoSupportedCommandInHistory()

var maskedCommands = new List<string>()
{
"New-AzResourceGroup -Name ***",
"New-AzVM -Location:*** -Name:***"
"Set-Content -Filter *** -Path *** -Value ***",
"Get-LogProperties -Name:***"
};

Assert.Equal(maskedCommands, _service.Commands);
Expand Down Expand Up @@ -174,8 +174,8 @@ public async Task VerifyNotTakeUnsupportedCommands()
{
var history = new List<string>()
{
"New-AzResourceGroup -Name:resourceGroup01",
"New-AzVM -Name hello -Location WestUS"
"Set-Content -Path C:\\Temp\\* -Filter *.txt -Value 'Empty'",
"Get-LogProperties -Name:'Windows PowerShell'"
};

_service.Commands = null;
Expand All @@ -200,8 +200,8 @@ public async Task VerifyNotTakeUnsupportedCommands()

var maskedCommands = new List<string>()
{
"New-AzResourceGroup -Name:***",
"New-AzVM -Location *** -Name ***"
"Set-Content -Filter *** -Path *** -Value ***",
"Get-LogProperties -Name:***"
};

Assert.Equal(maskedCommands, _service.Commands);
Expand All @@ -210,14 +210,14 @@ public async Task VerifyNotTakeUnsupportedCommands()
// When there is a new supported command, we'll use that for prediction.

_service.ResetRequestPredictionTask();
history.Add("Get-AzResourceGroup -Name ResourceGroup01");
history.Add("Clear-Content -Path '*' -Filter '*.log' -Force");
_azPredictor.OnCommandLineAccepted(MockObjects.PredictionClient, history);
await _service.RequestPredictionTaskCompletionSource.Task;

maskedCommands = new List<string>()
{
"New-AzVM -Location *** -Name ***",
"Get-AzResourceGroup -Name ***",
"Get-LogProperties -Name:***",
"Clear-Content -Filter *** -Force *** -Path ***"
};

Assert.Equal(maskedCommands, _service.Commands);
Expand All @@ -232,8 +232,8 @@ public async Task VerifyThreeSupportedCommands()
{
var history = new List<string>()
{
"New-AzResourceGroup -Name resourceGroup01",
"New-AzVM -Name:hello -Location:WestUS"
"Set-Content -Path C:\\Temp\\* -Filter *.txt -Value 'Empty'",
"Get-LogProperties -Name:'Windows PowerShell'"
};

_service.Commands = null;
Expand All @@ -244,14 +244,14 @@ public async Task VerifyThreeSupportedCommands()
await _service.RequestPredictionTaskCompletionSource.Task;

_service.ResetRequestPredictionTask();
history.Add("Get-AzResourceGroup -Name resourceGroup01");
history.Add("Clear-Content -Path C:\\Test\\Copy-Script.ps1 -Stream Zone.Identifier");
_azPredictor.OnCommandLineAccepted(MockObjects.PredictionClient, history);
await _service.RequestPredictionTaskCompletionSource.Task;

var maskedCommands = new List<string>()
{
"New-AzVM -Location:*** -Name:***",
"Get-AzResourceGroup -Name ***",
"Get-LogProperties -Name:***",
"Clear-Content -Path *** -Stream ***"
};

Assert.Equal(maskedCommands, _service.Commands);
Expand All @@ -267,7 +267,7 @@ public async Task VerifyUnsupportedAndSupportedCommands()
var history = new List<string>()
{
"git status",
"New-AzVM -Name:hello -Location:WestUS"
"Clear-Content -Path '*' -Filter '*.log' -Force"
};

_service.Commands = null;
Expand All @@ -280,7 +280,7 @@ public async Task VerifyUnsupportedAndSupportedCommands()
var maskedCommands = new List<string>()
{
AzPredictorConstants.CommandPlaceholder,
"New-AzVM -Location:*** -Name:***"
"Clear-Content -Filter *** -Force *** -Path ***"
};

Assert.Equal(maskedCommands, _service.Commands);
Expand All @@ -295,7 +295,7 @@ public async Task VerifySupportedAndUnsupportedCommands()
{
var history = new List<string>()
{
"New-AzVM -Name hello -Location WestUS",
"Clear-Variable -Name:my* -Scope Global",
"git status",
};

Expand All @@ -309,7 +309,7 @@ public async Task VerifySupportedAndUnsupportedCommands()
var maskedCommands = new List<string>()
{
AzPredictorConstants.CommandPlaceholder,
"New-AzVM -Location *** -Name ***",
"Clear-Variable -Name:*** -Scope ***",
};

Assert.Equal(maskedCommands, _service.Commands);
Expand All @@ -320,8 +320,8 @@ public async Task VerifySupportedAndUnsupportedCommands()
/// Verifies AzPredictor returns the same value as AzPredictorService for the prediction.
/// </summary>
[Theory]
[InlineData("new-azresourcegroup -name hello")]
[InlineData("Get-AzContext -Name")]
[InlineData("compare-object -referenceobject ref -differenceobject diff")]
[InlineData("Clear-Variable -Name my")]
public void VerifySuggestion(string userInput)
{
var predictionContext = PredictionContext.Create(userInput);
Expand Down Expand Up @@ -352,8 +352,8 @@ public void VerifySuggestionOnIncompleteCommand()
},
azContext);

var userInput = "New-AzResourceGroup -Name 'ResourceGroup01' -Location 'Central US' -WhatIf -";
var expected = "New-AzResourceGroup -Name 'ResourceGroup01' -Location 'Central US' -WhatIf -Tag value1";
var userInput = "Clear-Variable -Name my* -";
var expected = "Clear-Variable -Name my* -Scope Global";

var predictionContext = PredictionContext.Create(userInput);
var actual = localAzPredictor.GetSuggestion(MockObjects.PredictionClient, predictionContext, CancellationToken.None);
Expand Down
Loading