winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

ShowCommand.cs (6695B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="ShowCommand.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace AppInstallerCLIE2ETests
      8 {
      9     using AppInstallerCLIE2ETests.Helpers;
     10     using NUnit.Framework;
     11 
     12     /// <summary>
     13     /// Test show command.
     14     /// </summary>
     15     public class ShowCommand : BaseCommand
     16     {
     17         /// <summary>
     18         /// Test show with no args.
     19         /// </summary>
     20         [Test]
     21         public void ShowWithNoArgs()
     22         {
     23             var result = TestCommon.RunAICLICommand("show", string.Empty);
     24             Assert.AreEqual(Constants.ErrorCode.ERROR_INVALID_CL_ARGUMENTS, result.ExitCode);
     25         }
     26 
     27         /// <summary>
     28         /// Test show no match.
     29         /// </summary>
     30         [Test]
     31         public void ShowWithNoMatches()
     32         {
     33             // Show with 0 search match shows a "please refine input"
     34             var result = TestCommon.RunAICLICommand("show", $"DoesNotExist");
     35             Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode);
     36             Assert.True(result.StdOut.Contains("No package found matching input criteria."));
     37         }
     38 
     39         /// <summary>
     40         /// Test show with substring match.
     41         /// </summary>
     42         [Test]
     43         public void ShowWithSubstringMatch()
     44         {
     45             // Show with a substring match still returns 0 results
     46             var result = TestCommon.RunAICLICommand("show", $"AppInstallerTest");
     47             Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode);
     48             Assert.True(result.StdOut.Contains("No package found matching input criteria."));
     49         }
     50 
     51         /// <summary>
     52         /// Test show with name match.
     53         /// </summary>
     54         [Test]
     55         public void ShowWithNameMatch()
     56         {
     57             var result = TestCommon.RunAICLICommand("show", $"--name testexampleinstaller");
     58             Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
     59             Assert.True(result.StdOut.Contains("Found TestExampleInstaller [AppInstallerTest.TestExampleInstaller]"));
     60             Assert.True(result.StdOut.Contains("TestExampleInstaller"));
     61             Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"));
     62         }
     63 
     64         /// <summary>
     65         /// Test show with id match.
     66         /// </summary>
     67         [Test]
     68         public void ShowWithIDMatch()
     69         {
     70             var result = TestCommon.RunAICLICommand("show", $"--id appinstallertest.testexampleinstaller");
     71             Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
     72             Assert.True(result.StdOut.Contains("Found TestExampleInstaller [AppInstallerTest.TestExampleInstaller]"));
     73             Assert.True(result.StdOut.Contains("TestExampleInstaller"));
     74             Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"));
     75         }
     76 
     77         /// <summary>
     78         /// Test show versions.
     79         /// </summary>
     80         [Test]
     81         public void ShowWithVersions()
     82         {
     83             // Show with --versions list the versions
     84             var result = TestCommon.RunAICLICommand("show", $"TestExampleInstaller --versions");
     85             Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
     86             Assert.True(result.StdOut.Contains("TestExampleInstaller"));
     87             Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"));
     88             Assert.True(result.StdOut.Contains("1.2.3.4"));
     89         }
     90 
     91         /// <summary>
     92         /// Test show with exact match name.
     93         /// </summary>
     94         [Test]
     95         public void ShowWithExactName()
     96         {
     97             var result = TestCommon.RunAICLICommand("show", $"--exact TestExampleInstaller");
     98             Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
     99             Assert.True(result.StdOut.Contains("Found TestExampleInstaller [AppInstallerTest.TestExampleInstaller]"));
    100             Assert.True(result.StdOut.Contains("TestExampleInstaller"));
    101             Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"));
    102         }
    103 
    104         /// <summary>
    105         /// Test show with exact id.
    106         /// </summary>
    107         [Test]
    108         public void ShowWithExactID()
    109         {
    110             var result = TestCommon.RunAICLICommand("show", $"--exact AppInstallerTest.TestExampleInstaller");
    111             Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
    112             Assert.True(result.StdOut.Contains("Found TestExampleInstaller [AppInstallerTest.TestExampleInstaller]"));
    113             Assert.True(result.StdOut.Contains("TestExampleInstaller"));
    114             Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"));
    115         }
    116 
    117         /// <summary>
    118         /// Test show with exact args.
    119         /// </summary>
    120         [Test]
    121         public void ShowWithExactArgCaseSensitivity()
    122         {
    123             var result = TestCommon.RunAICLICommand("show", $"--exact testexampleinstaller");
    124             Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode);
    125             Assert.True(result.StdOut.Contains("No package found matching input criteria."));
    126         }
    127 
    128         /// <summary>
    129         /// Test show with installer type.
    130         /// </summary>
    131         [Test]
    132         public void ShowWithInstallerTypeArg()
    133         {
    134             var result = TestCommon.RunAICLICommand("show", $"--id AppInstallerTest.TestMultipleInstallers --installer-type msi");
    135             Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
    136             Assert.True(result.StdOut.Contains("Found TestMultipleInstallers [AppInstallerTest.TestMultipleInstallers]"));
    137             Assert.True(result.StdOut.Contains("Installer Type: msi"));
    138         }
    139 
    140         /// <summary>
    141         /// Test show with an archive installer type.
    142         /// </summary>
    143         [Test]
    144         public void ShowWithZipInstallerTypeArg()
    145         {
    146             var result = TestCommon.RunAICLICommand("show", $"--id AppInstallerTest.TestMultipleInstallers --installer-type zip");
    147             Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
    148             Assert.True(result.StdOut.Contains("Found TestMultipleInstallers [AppInstallerTest.TestMultipleInstallers]"));
    149             Assert.True(result.StdOut.Contains("Installer Type: exe (zip)"));
    150         }
    151     }
    152 }