|
1 | 1 | using System.Collections.ObjectModel; |
| 2 | +using System.IO; |
2 | 3 | using System.Threading.Channels; |
3 | 4 | using System.Threading.Tasks; |
4 | 5 | using Microsoft.Extensions.Logging; |
@@ -651,6 +652,74 @@ public void RegistryToggle_GetState_MatchesMultipleOnValues() |
651 | 652 | CleanupTestKeys(); |
652 | 653 | } |
653 | 654 |
|
| 655 | + [Fact] |
| 656 | + public void RegistryToggle_GetState_HwSchModeStyle_OnValue2_ReturnsTrue() |
| 657 | + { |
| 658 | + RegistryService.Write(NewCall(), new RegistryItem(TestKeyPath, "HwSchModeOnTest", 2)); |
| 659 | + |
| 660 | + var toggle = new RegistryToggle |
| 661 | + { |
| 662 | + Path = TestKeyPath, |
| 663 | + Name = "HwSchModeOnTest", |
| 664 | + OnValues = [2], |
| 665 | + OffValues = [1], |
| 666 | + DefaultValue = 1, |
| 667 | + }; |
| 668 | + |
| 669 | + Assert.True(toggle.GetState()); |
| 670 | + |
| 671 | + CleanupTestKeys(); |
| 672 | + } |
| 673 | + |
| 674 | + [Fact] |
| 675 | + public void RegistryToggle_GetState_HwSchModeStyle_OffValue1_ReturnsFalse() |
| 676 | + { |
| 677 | + RegistryService.Write(NewCall(), new RegistryItem(TestKeyPath, "HwSchModeOffTest", 1)); |
| 678 | + |
| 679 | + var toggle = new RegistryToggle |
| 680 | + { |
| 681 | + Path = TestKeyPath, |
| 682 | + Name = "HwSchModeOffTest", |
| 683 | + OnValues = [2], |
| 684 | + OffValues = [1], |
| 685 | + DefaultValue = 1, |
| 686 | + }; |
| 687 | + |
| 688 | + Assert.False(toggle.GetState()); |
| 689 | + |
| 690 | + CleanupTestKeys(); |
| 691 | + } |
| 692 | + |
| 693 | + [Fact] |
| 694 | + public void RegistryToggle_GetState_HwSchModeStyle_AbsentValue_ReturnsFalse() |
| 695 | + { |
| 696 | + var toggle = new RegistryToggle |
| 697 | + { |
| 698 | + Path = TestKeyPath, |
| 699 | + Name = "HwSchModeAbsentTest", |
| 700 | + OnValues = [2], |
| 701 | + OffValues = [1], |
| 702 | + DefaultValue = 1, |
| 703 | + }; |
| 704 | + |
| 705 | + Assert.False(toggle.GetState()); |
| 706 | + } |
| 707 | + |
| 708 | + [Fact] |
| 709 | + public void RegistryToggle_GetState_FailedRead_ThrowsInsteadOfReadingAsOff() |
| 710 | + { |
| 711 | + var toggle = new RegistryToggle |
| 712 | + { |
| 713 | + Path = @"HKZZ\Software\TestOptimizerDuckCustomize", |
| 714 | + Name = "HwSchModeFailTest", |
| 715 | + OnValues = [2], |
| 716 | + OffValues = [1], |
| 717 | + DefaultValue = 1, |
| 718 | + }; |
| 719 | + |
| 720 | + Assert.Throws<IOException>(() => toggle.GetState()); |
| 721 | + } |
| 722 | + |
654 | 723 | #endregion |
655 | 724 |
|
656 | 725 | #region SettingOption Bindings tests |
|
0 commit comments