winget-cli

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

WinGetUtilCompareVersions.cs (1713B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="WinGetUtilCompareVersions.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace AppInstallerCLIE2ETests.WinGetUtil
      8 {
      9     using NUnit.Framework;
     10 
     11     /// <summary>
     12     /// Test winget util compare versions.
     13     /// </summary>
     14     public class WinGetUtilCompareVersions
     15     {
     16         /// <summary>
     17         /// Test compare versions.
     18         /// </summary>
     19         /// <param name="version1">Version 1.</param>
     20         /// <param name="version2">Version 2.</param>
     21         /// <param name="expectedResult">Expected result.</param>
     22         [Test]
     23         //// V1 = V2
     24         [TestCase("1.0.0.0", "1.0.0.0", 0)]
     25         [TestCase("1.0.0", "1.0.0.0", 0)]
     26         [TestCase("1.0", "1.0.0.0", 0)]
     27         [TestCase("1", "1.0.0.0", 0)]
     28         //// V1 > V2
     29         [TestCase("1.0.0.1", "1.0.0.0", 1)]
     30         [TestCase("1.0.1.0", "1.0.0.0", 1)]
     31         [TestCase("1.1.0.0", "1.0.0.0", 1)]
     32         [TestCase("2.0.0.0", "1.0.0.0", 1)]
     33         //// V1 < V2
     34         [TestCase("1.0.0.0", "1.0.0.1", -1)]
     35         [TestCase("1.0.0.0", "1.0.1.0", -1)]
     36         [TestCase("1.0.0.0", "1.1.0.0", -1)]
     37         [TestCase("1.0.0.0", "2.0.0.0", -1)]
     38         public void WinGetUtil_CompareVersions(string version1, string version2, int expectedResult)
     39         {
     40             // Compare versions
     41             WinGetUtilWrapper.WinGetCompareVersions(version1, version2, out int result);
     42             Assert.AreEqual(expectedResult, result);
     43         }
     44     }
     45 }