// [Fact] private void DumpProcessorFeatures() { foreach (ProcessorFeature feature in Enum.GetValues(typeof(ProcessorFeature))) { Debug.WriteLine($"{feature}: {SystemInformationMethods.IsProcessorFeaturePresent(feature)}"); } }
public void IsProcessorFeaturePresent() { // We shouldn't be able to run on the original Pentium, so this should always be false. SystemInformationMethods.IsProcessorFeaturePresent(ProcessorFeature.PF_FLOATING_POINT_PRECISION_ERRATA).Should().BeFalse(); // I don't think any platform doesn't support this SystemInformationMethods.IsProcessorFeaturePresent(ProcessorFeature.PF_COMPARE_EXCHANGE_DOUBLE).Should().BeTrue(); }
public void ExpandEnvironmentVariables_Long() { string longValue = new string('a', 100); try { Environment.SetEnvironmentVariable("ExpandEnvironmentVariables_Long", longValue); SystemInformationMethods.ExpandEnvironmentVariables(@"%ExpandEnvironmentVariables_Long%"). Should().Be(longValue); } finally { Environment.SetEnvironmentVariable("ExpandEnvironmentVariables_Long", null); } }
// [Fact] private void DumpComputerNameFormats() { foreach (COMPUTER_NAME_FORMAT format in Enum.GetValues(typeof(COMPUTER_NAME_FORMAT))) { try { string name = SystemInformationMethods.GetComputerName(format) ?? "<null>"; Debug.WriteLine($"{format}: '{name}'"); } catch (Exception e) { Debug.WriteLine($"{format}: FAILED- {e.Message}"); } } }
public void GetTokenPrimaryGroupSid_ForCurrentProcess() { SID sid; using (var token = AuthorizationMethods.OpenProcessToken(AccessTokenRights.Read)) { token.IsInvalid.Should().BeFalse(); sid = AuthorizationMethods.GetTokenPrimaryGroupSid(token); } AuthorizationMethods.IsValidSid(ref sid).Should().BeTrue(); AccountSidInformation info = AuthorizationMethods.LookupAccountSidLocal(sid); info.Name.Should().Be(SystemInformationMethods.GetUserName()); }
public void GetSidForCreatedFile() { using (var cleaner = new TestFileCleaner()) { using (var handle = FileMethods.CreateFile(cleaner.GetTestPath(), CreationDisposition.CreateNew)) { handle.IsInvalid.Should().BeFalse(); FileMethods.QueryOwner(handle, out SID sid); sid.IdentifierAuthority.Should().Be(SID_IDENTIFIER_AUTHORITY.NT); AccountSidInformation info = AuthorizationMethods.LookupAccountSidLocal(sid); info.Usage.Should().Be(SidNameUse.User); info.Name.Should().Be(SystemInformationMethods.GetUserName()); } } }
public void ExpandEnvironmentVariables_Existing() { SystemInformationMethods.ExpandEnvironmentVariables(@"%COMPUTERNAME%"). Should().Be(Environment.GetEnvironmentVariable("COMPUTERNAME")); }
public void GetComputerName_NetBIOS() { SystemInformationMethods.GetComputerName(COMPUTER_NAME_FORMAT.ComputerNameNetBIOS) .Should().Be(SystemInformationMethods.GetComputerName()); }
public void GetUserNameDisplay() { SystemInformationMethods.GetUserName(EXTENDED_NAME_FORMAT.NameDisplay).Should().NotBeNullOrWhiteSpace(); }
public void GetUserNameSam() { // Should be DOMAIN\user or COMPUTER\user SystemInformationMethods.GetUserName(EXTENDED_NAME_FORMAT.NameSamCompatible) .Should().Be($"{Environment.GetEnvironmentVariable("USERDOMAIN")}\\{Environment.GetEnvironmentVariable("USERNAME")}"); }
public void GetSuiteMask() { SystemInformationMethods.GetSuiteMask().Should().HaveFlag(SuiteMask.VER_SUITE_SINGLEUSERTS); }
public void GetCurrentUserName() { SystemInformationMethods.GetUserName().Should().Be(Environment.GetEnvironmentVariable("USERNAME")); }
public void GetComputerName() { SystemInformationMethods.GetComputerName().Should().Be(Environment.GetEnvironmentVariable("COMPUTERNAME")); }
public void CeipIsOptedIn() { // Can't really validate this, just make sure it doesn't blow up. SystemInformationMethods.CeipIsOptedIn(); }
public static SYSTEMTIME GetLocalTime() => SystemInformationMethods.GetLocalTime();