-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathConfigureListCommand.cs
More file actions
105 lines (91 loc) · 4.64 KB
/
Copy pathConfigureListCommand.cs
File metadata and controls
105 lines (91 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// -----------------------------------------------------------------------------
// <copyright file="ConfigureListCommand.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
// -----------------------------------------------------------------------------
namespace AppInstallerCLIE2ETests
{
using System.IO;
using AppInstallerCLIE2ETests.Helpers;
using NUnit.Framework;
/// <summary>
/// `Configure list` command tests.
/// </summary>
public class ConfigureListCommand
{
private const string ConfigureWithAgreementsAndVerbose = "configure --accept-configuration-agreements --verbose";
private const string ConfigureTestRepoFile = "Configure_TestRepo.yml";
/// <summary>
/// Teardown done once after all the tests here.
/// </summary>
[OneTimeTearDown]
public void OneTimeTeardown()
{
this.DeleteTxtFiles();
}
/// <summary>
/// Applies a configuration, then verifies that it is in the overall list.
/// </summary>
[Test]
public void ListAllConfigurations()
{
var result = TestCommon.RunAICLICommand(ConfigureWithAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
Assert.That(result.ExitCode, Is.EqualTo(0));
result = TestCommon.RunAICLICommand("configure list", "--verbose");
Assert.That(result.ExitCode, Is.EqualTo(0));
Assert.That(result.StdOut.Contains(ConfigureTestRepoFile), Is.True);
}
/// <summary>
/// Applies a configuration (to ensure at least one exists), gets the overall list, then the details about the first configuration.
/// </summary>
[Test]
public void ListSpecificConfiguration()
{
var result = TestCommon.RunAICLICommand(ConfigureWithAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
Assert.That(result.ExitCode, Is.EqualTo(0));
string guid = TestCommon.GetConfigurationInstanceIdentifierFor(ConfigureTestRepoFile);
result = TestCommon.RunAICLICommand("configure list", $"-h {guid}");
Assert.That(result.ExitCode, Is.EqualTo(0));
Assert.That(result.StdOut.Contains(guid), Is.True);
Assert.That(result.StdOut.Contains(ConfigureTestRepoFile), Is.True);
}
/// <summary>
/// Applies a configuration (to ensure at least one exists), gets the overall list, then the removes the first configuration.
/// </summary>
[Test]
public void RemoveConfiguration()
{
var result = TestCommon.RunAICLICommand(ConfigureWithAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
Assert.That(result.ExitCode, Is.EqualTo(0));
string guid = TestCommon.GetConfigurationInstanceIdentifierFor(ConfigureTestRepoFile);
result = TestCommon.RunAICLICommand("configure list", $"-h {guid} --remove");
Assert.That(result.ExitCode, Is.EqualTo(0));
result = TestCommon.RunAICLICommand("configure list", "--verbose");
Assert.That(result.ExitCode, Is.EqualTo(0));
Assert.That(result.StdOut.Contains(guid), Is.False);
}
/// <summary>
/// Applies a configuration (to ensure at least one exists), gets the overall list, then the outputs the first configuration.
/// </summary>
[Test]
public void OutputConfiguration()
{
var result = TestCommon.RunAICLICommand(ConfigureWithAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
Assert.That(result.ExitCode, Is.EqualTo(0));
string guid = TestCommon.GetConfigurationInstanceIdentifierFor(ConfigureTestRepoFile);
string tempFile = TestCommon.GetRandomTestFile(".yml");
result = TestCommon.RunAICLICommand("configure list", $"-h {guid} --output {tempFile}");
Assert.That(result.ExitCode, Is.EqualTo(0));
result = TestCommon.RunAICLICommand("configure validate", $"--verbose {tempFile}");
Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
}
private void DeleteTxtFiles()
{
// Delete all .txt files in the test directory; they are placed there by the tests
foreach (string file in Directory.GetFiles(TestCommon.GetTestDataFile("Configuration"), "*.txt"))
{
File.Delete(file);
}
}
}
}