private string GetComponentValue(string rootParentDeviceName, string lsblkOutput, string udevadmOutput) { var commandExecutorMock = new Mock <ICommandExecutor>(); commandExecutorMock.Setup(x => x.Execute("lsblk -f -J")).Returns(lsblkOutput); commandExecutorMock.Setup(x => x.Execute($"udevadm info --query=all --name=/dev/{rootParentDeviceName} | grep ID_SERIAL=")).Returns(udevadmOutput); var component = new LinuxRootDriveSerialNumberDeviceIdComponent(commandExecutorMock.Object); var value = component.GetValue(); return(value); }
/// <summary> /// Return the system drive's serial number of device. /// </summary> /// <returns>The system drive's serial number of device.</returns> public static string GetSystemDriveSerialNumber() { IDeviceIdComponent comp; if (OS.IsWindows) { comp = new SystemDriveSerialNumberDeviceIdComponent(); } else if (OS.IsLinux) { comp = new LinuxRootDriveSerialNumberDeviceIdComponent(); } else { comp = new UnsupportedDeviceIdComponent("SystemDriveSerialNumber"); } return(comp.GetValue()); }