BasicTests.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using System;
 6  using Microsoft.CmdPal.Ext.System.Helpers;
 7  using Microsoft.VisualStudio.TestTools.UnitTesting;
 8  
 9  namespace Microsoft.CmdPal.Ext.System.UnitTests;
10  
11  [TestClass]
12  public class BasicTests
13  {
14      [TestMethod]
15      public void IconsHelperTest()
16      {
17          // Assert
18          Assert.IsNotNull(Icons.FirmwareSettingsIcon);
19          Assert.IsNotNull(Icons.LockIcon);
20          Assert.IsNotNull(Icons.LogoffIcon);
21          Assert.IsNotNull(Icons.NetworkAdapterIcon);
22          Assert.IsNotNull(Icons.RecycleBinIcon);
23          Assert.IsNotNull(Icons.RestartIcon);
24          Assert.IsNotNull(Icons.RestartShellIcon);
25          Assert.IsNotNull(Icons.ShutdownIcon);
26          Assert.IsNotNull(Icons.SleepIcon);
27      }
28  
29      [TestMethod]
30      public void Win32HelpersTest()
31      {
32          // Setup & Act
33          // These methods should not throw exceptions
34          var firmwareType = Win32Helpers.GetSystemFirmwareType();
35  
36          // Assert
37          // Just testing that they don't throw exceptions
38          Assert.IsTrue(Enum.IsDefined(typeof(FirmwareType), firmwareType));
39      }
40  
41      [TestMethod]
42      public void NetworkConnectionPropertiesTest()
43      {
44          // Test that network connection properties can be accessed without throwing exceptions
45          try
46          {
47              var networkPropertiesList = NetworkConnectionProperties.GetList();
48  
49              // If we have network connections, test accessing their properties
50              if (networkPropertiesList.Count > 0)
51              {
52                  var networkProperties = networkPropertiesList[0];
53  
54                  // Access properties (these used to be methods)
55                  var ipv4 = networkProperties.IPv4;
56                  var ipv6 = networkProperties.IPv6Primary;
57                  var macAddress = networkProperties.PhysicalAddress;
58  
59                  // Test passes if no exceptions are thrown
60                  Assert.IsTrue(true);
61              }
62              else
63              {
64                  // If no network connections, test still passes
65                  Assert.IsTrue(true);
66              }
67          }
68          catch
69          {
70              Assert.Fail("Network properties should not throw exceptions");
71          }
72      }
73  }