public void FormatMac_NonMac() { var input = "Try me"; var result = NetworkAdapterDeviceIdComponent.FormatMacAddress(input); result.ShouldBeEquivalentTo(input, "Non MAC addresses are not formatted"); }
public void FormatMac_64BitMac() { var input = "AABBCCDDEEFF0011"; var result = NetworkAdapterDeviceIdComponent.FormatMacAddress(input); result.ShouldBeEquivalentTo("AA:BB:CC:DD:EE:FF:00:11", "MAC address should be formatted"); }
public void GetValue() { var component = new NetworkAdapterDeviceIdComponent(true, false); component.GetValue(); }
public SRClient GetClientDevice() { DeviceIdBuilder cDeviceId = new DeviceIdBuilder(); cDeviceId.AddProcessorId(); cDeviceId.AddMachineName(); cDeviceId.AddOSVersion(); cDeviceId.AddSystemUUID(); cDeviceId.AddUserName(); // DeviceIdComponent dc = new DeviceIdComponent("test", ); var wmi = new ManagementObjectSearcher("select * from Win32_OperatingSystem") .Get() .Cast <ManagementObject>() .First(); var cpu = new ManagementObjectSearcher("select * from Win32_Processor") .Get() .Cast <ManagementObject>() .First(); var cMachineName = Environment.MachineName; var cExePath = Environment.CommandLine; var cOSVersion = Environment.OSVersion; var cProcessorID = new WmiDeviceIdComponent("ProcessorId", "Win32_Processor", "ProcessorId").GetValue(); var cProcessorCount = System.Environment.ProcessorCount; var cUUID = new WmiDeviceIdComponent("SystemUUID", "Win32_ComputerSystemProduct", "UUID").GetValue(); var cNetwork = new NetworkAdapterDeviceIdComponent(false, false).GetValue(); var c = new SRClient(); c.MachineName = cMachineName; c.DeviceID = cDeviceId.ToString(); c.FirstRun = DateTime.Now; c.LastActive = DateTime.Now; c.ExePath = cExePath; c.UUID = cUUID; var cOS = new ClientOS(); cOS.Name = ((string)wmi["Caption"]).Trim();; cOS.Build = ((string)wmi["BuildNumber"]).StrToInt(); cOS.Version = (string)wmi["Version"]; cOS.SerialNumber = (string)wmi["SerialNumber"]; cOS.Architecture = (string)wmi["OSArchitecture"]; cOS.MaxProcessCount = (uint)wmi["MaxNumberOfProcesses"]; cOS.MaxProcessRAM = (ulong)wmi["MaxProcessMemorySize"]; c.OS = new List <ClientOS>() { cOS }; var cCPU = new ClientCPU(); cCPU.ID = (string)cpu["ProcessorId"]; cCPU.Name = (string)cpu["Name"]; cCPU.Description = (string)cpu["Caption"]; // cCPU.Socket = (string)cpu["SocketDesignation"]; // cCPU.AddressWidth = (ushort)cpu["AddressWidth"]; // cCPU.DataWidth = (ushort)cpu["DataWidth"]; // cCPU.Architecture = (ushort)cpu["Architecture"]; // cCPU.SpeedMHz = (uint)cpu["MaxClockSpeed"]; // cCPU.BusSpeedMHz = (uint)cpu["ExtClock"]; // cCPU.L2Cache = (uint)cpu["L2CacheSize"] * (ulong)1024; // cCPU.L3Cache = (uint)cpu["L3CacheSize"] * (ulong)1024; // cCPU.Cores = (uint)cpu["NumberOfCores"]; // cCPU.Threads = (uint)cpu["NumberOfLogicalProcessors"]; c.CPU = new List <ClientCPU>() { cCPU }; // var js = JsonConvert.SerializeObject(c); // Debug.WriteLine(js); return(c); }