123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- using System;
- using System.Linq;
- using System.Threading.Tasks;
- using Masuit.Tools.Hardware;
- using Xunit;
- namespace Masuit.Tools.Abstractions;
- public class SystemInfo_UnitTest
- {
- [Fact]
- public void SystemInfo_IsWinPlatform()
- {
- var res = SystemInfo.IsWinPlatform;
- if (Environment.OSVersion.Platform is PlatformID.MacOSX or PlatformID.Unix)
- {
- Assert.False(res);
- }
- else
- {
- Assert.True(res);
- }
- }
- [Fact]
- public void SystemInfo_ProcessorCount_MoreThanZero()
- {
- int res = SystemInfo.ProcessorCount;
- Assert.True(res > 0);
- }
- [Fact]
- public void SystemInfo_CpuLoad_IfNotWinPlatform()
- {
- float res = SystemInfo.CpuLoad;
- Assert.True(res >= 0);
- }
- [Fact]
- public async Task SystemInfo_GetCpuUsageForProcess_MoreThanZero()
- {
- double res = await SystemInfo.GetCpuUsageForProcess();
- Assert.True(res > 0);
- }
- [Fact]
- public void SystemInfo_GetCpuCount_MoreThanZero()
- {
- double res = SystemInfo.GetCpuCount();
- Assert.True(res > 0);
- }
- [Fact]
- public void SystemInfo_GetCpuInfo_IfNotWinPlatform()
- {
- var res = SystemInfo.GetCpuInfo();
- Assert.True(res.Count > 0);
- }
- [Fact]
- public void SystemInfo_MemoryAvailable_IfNotWinPlatform()
- {
- var res = SystemInfo.MemoryAvailable;
- Assert.True(res > 0);
- }
- [Fact]
- public void SystemInfo_PhysicalMemory_IfNotWinPlatform()
- {
- var res = SystemInfo.PhysicalMemory;
- Assert.True(res > 0);
- }
- [Fact]
- public void SystemInfo_GetMemoryVData_IfNotWinPlatform()
- {
- var res = SystemInfo.GetMemoryVData();
- Assert.False(string.IsNullOrEmpty(res));
- }
- [Fact]
- public void SystemInfo_GetUsageVirtualMemory_IfNotWinPlatform()
- {
- var res = SystemInfo.GetUsageVirtualMemory();
- Assert.True(res > 0);
- }
- [Fact]
- public void SystemInfo_GetUsedVirtualMemory_IfNotWinPlatform()
- {
- var res = SystemInfo.GetUsedVirtualMemory();
- Assert.True(res > 0);
- }
- [Fact]
- public void SystemInfo_GetTotalVirtualMemory_IfNotWinPlatform()
- {
- var res = SystemInfo.GetTotalVirtualMemory();
- Assert.True(res > 0);
- }
- [Fact]
- public void SystemInfo_GetMemoryPData_IfNotWinPlatform()
- {
- var res = SystemInfo.GetMemoryPData();
- Assert.False(string.IsNullOrEmpty(res));
- }
- [Fact]
- public void SystemInfo_GetTotalPhysicalMemory_IfNotWinPlatform()
- {
- var res = SystemInfo.GetTotalPhysicalMemory();
- Assert.True(res > 0);
- }
- [Fact]
- public void SystemInfo_GetFreePhysicalMemory_IfNotWinPlatform()
- {
- var res = SystemInfo.GetFreePhysicalMemory();
- Assert.True(res > 0);
- }
- [Fact]
- public void SystemInfo_GetUsedPhysicalMemory_IfNotWinPlatform()
- {
- var res = SystemInfo.GetUsedPhysicalMemory();
- Assert.True(res > 0);
- }
- [Fact]
- public void SystemInfo_GetDiskData_Read_IfNotWinPlatform()
- {
- var res = SystemInfo.GetDiskData(DiskData.Read);
- Assert.True(res >= 0);
- }
- [Fact]
- public void SystemInfo_GetDiskData_Write_IfNotWinPlatform()
- {
- var res = SystemInfo.GetDiskData(DiskData.Write);
- Assert.True(res >= 0);
- }
- [Fact]
- public void SystemInfo_GetDiskData_ReadAndWrite_IfNotWinPlatform()
- {
- var res = SystemInfo.GetDiskData(DiskData.ReadAndWrite);
- Assert.True(res >= 0);
- }
- [Fact]
- public void SystemInfo_GetDiskInfo_IfNotWinPlatform()
- {
- var res = SystemInfo.GetDiskInfo();
- Assert.True(res.Count > 0);
- }
- [Fact]
- public void SystemInfo_GetNetData_Sent_IfNotWinPlatform()
- {
- var res = SystemInfo.GetNetData(NetData.Sent);
- Assert.True(res == 0);
- }
- [Fact]
- public void SystemInfo_GetNetData_Received_IfNotWinPlatform()
- {
- var res = SystemInfo.GetNetData(NetData.Received);
- Assert.True(res >= 0);
- }
- [Fact]
- public void SystemInfo_GetNetData_ReceivedAndSent_IfNotWinPlatform()
- {
- var res = SystemInfo.GetNetData(NetData.ReceivedAndSent);
- Assert.True(res >= 0);
- }
- [Fact]
- public void SystemInfo_GetMacAddress_IfNotWinPlatform()
- {
- var res = SystemInfo.GetMacAddress();
- Assert.True(res.Any());
- }
- [Fact]
- public void SystemInfo_GetLocalUsedIP_IfNotWinPlatform()
- {
- var res = SystemInfo.GetLocalUsedIP();
- Assert.True(res != null);
- }
- [Fact]
- public void SystemInfo_GetIPAddressWMI_IfNotWinPlatform()
- {
- var res = SystemInfo.GetIPAddressWMI();
- Assert.False(string.IsNullOrEmpty(res));
- }
- [Fact]
- public void SystemInfo_GetLocalIPs()
- {
- var res = SystemInfo.GetLocalIPs();
- Assert.True(res.Count > 0);
- }
- [Fact]
- public void SystemInfo_GetNetworkCardAddress_IfNotWinPlatform()
- {
- var res = SystemInfo.GetNetworkCardAddress();
- Assert.False(string.IsNullOrEmpty(res));
- }
- [Fact]
- public void SystemInfo_FindAllApps_IfNotWinPlatform()
- {
- var res = SystemInfo.FindAllApps(0);
- Assert.Equal(res.Count, 0);
- }
- [Fact]
- public void SystemInfo_GetSystemType()
- {
- var res = SystemInfo.GetSystemType();
- Assert.Equal("x64-based PC", res);
- }
- }
|