Ejemplo n.º 1
0
        public void TestGetFreeMemory()
        {
#if !(NETCOREAPP2_0)
            var windowsSystemInfo = new WMISystemInfo();
            var wmiMem            = windowsSystemInfo.GetFreeMemoryMB();
            Console.WriteLine("WMI Free memory:  {0:F2} MB", wmiMem);
#endif

            // Use P/Invoke to access kernel32.dll
            var wpsi    = new WindowsSystemInfo();
            var pinvMem = wpsi.GetFreeMemoryMB();
            Console.WriteLine("PInv Free memory: {0:F2} MB", pinvMem);

#if !(NETCOREAPP2_0)
            Assert.AreEqual(wmiMem, pinvMem, 20);
#endif
        }