public void CreateTheRegValue_WhenCalledWithHKLM64()
            {
                // Arrange
                SUT         action      = new SUT(Tools.GetXmlFragment("AddRegValueToHKLM64.CustAct"));
                RegistryKey hklm        = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64);
                RegistryKey targetKey   = hklm.OpenSubKey(action.RegKey, true);
                var         finalResult = Tools.GetReturnCodeAction();
                object      newValue    = null;

                // Act
                if (targetKey != null)
                {
                    targetKey.DeleteValue(action.ValueName, false);
                }
                action.Run(ref finalResult);
                if (targetKey == null)
                {
                    targetKey = hklm.OpenSubKey(action.RegKey, false);
                }
                newValue = targetKey.GetValue(action.ValueName, null);

                // Assert
                Assert.IsNotNull(newValue);
                Assert.AreEqual(action.Data, newValue);
            }
            public void ProperlyInitializeValueType_WhenCalledWithReg_DWORD()
            {
                // Arrange
                SUT action = new SUT(Tools.GetXmlFragment("AddRegValueToHKLM64_Reg_DWORD.CustAct"));

                // Act

                // Assert
                Assert.AreEqual(action.ValueType, "REG_DWORD");
            }
            public void ProperlyInitializeProperties_WhenCalledWithHKLM64()
            {
                // Arrange
                SUT action = new SUT(Tools.GetXmlFragment("AddRegValueToHKLM64.CustAct"));

                // Act

                // Assert
                Assert.AreEqual(action.Hive, "HKey_Local_Machine");
                Assert.AreEqual(action.RegKey, @"SOFTWARE\EasyCompany\Wsus Package Publisher\Test");
                Assert.AreEqual(action.ValueName, "DisplayVersion");
                Assert.AreEqual(action.Data, "45.4.2.0");
                Assert.AreEqual(action.ValueType, "REG_SZ");
                Assert.IsFalse(action.UseReg32);
            }
            public void ReturnCorrectStringArray_WhenCalledWithOneData()
            {
                // Arrange
                SUT    action   = new SUT(Tools.GetXmlFragment("AddRegValueToHKCU_Reg_MULTI_SZ.CustAct"));
                string testData = @"Data1";

                string[] actualData;

                // Act
                actualData = action.GetStringData(testData);

                // Assert
                Assert.AreEqual(1, actualData.Length);
                Assert.AreEqual("Data1", actualData[0]);
            }
            public void ReturnCorrectStringArray_WhenCalledWithTwoDataAndEscapedBackslash()
            {
                // Arrange
                SUT    action   = new SUT(Tools.GetXmlFragment("AddRegValueToHKCU_Reg_MULTI_SZ.CustAct"));
                string testData = @"Data1\Data2\\Data3";

                string[] actualData;

                // Act
                actualData = action.GetStringData(testData);

                // Assert
                Assert.AreEqual(2, actualData.Length);
                Assert.AreEqual("Data1", actualData[0]);
                Assert.AreEqual(@"Data2\Data3", actualData[1]);
            }
            public void CreateRegValue_WhenCalledWithHKCU()
            {
                // Arrange
                SUT         action      = new SUT(Tools.GetXmlFragment("AddRegValueToHKCU.CustAct"));
                RegistryKey hkcu        = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, Microsoft.Win32.RegistryView.Registry32);
                RegistryKey targetKey   = hkcu.OpenSubKey(action.RegKey, true);
                var         finalResult = Tools.GetReturnCodeAction();
                object      newValue    = null;

                // Act
                targetKey.DeleteValue(action.ValueName, false);
                action.Run(ref finalResult);
                newValue = targetKey.GetValue(action.ValueName, null);

                // Assert
                Assert.IsNotNull(newValue);
                Assert.AreEqual(action.Data, newValue);
            }
            public void CreateAReg_SzValue_WhenCalledWithReg_EXPAND_SZ()
            {
                // Arrange
                SUT               action      = new SUT(Tools.GetXmlFragment("AddRegValueToHKCU_Reg_EXPAND_SZ.CustAct"));
                RegistryKey       hkcu        = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, Microsoft.Win32.RegistryView.Registry32);
                RegistryKey       targetKey   = hkcu.OpenSubKey(action.RegKey, true);
                var               finalResult = Tools.GetReturnCodeAction();
                object            newValue    = null;
                RegistryValueKind kindOfNewValue;

                // Act
                targetKey.DeleteValue(action.ValueName, false);
                action.Run(ref finalResult);
                newValue       = targetKey.GetValue(action.ValueName, null);
                kindOfNewValue = targetKey.GetValueKind(action.ValueName);

                // Assert
                Assert.IsNotNull(newValue);
                Assert.AreEqual(RegistryValueKind.ExpandString.ToString(), kindOfNewValue.ToString(), true);
            }