Пример #1
0
        public static RegState AddExtend(State state, string description, string ext, string args, ref RegState final, ref bool pass)
        {
            state.AddReport(description);
            var initial = new RegState();

            initial.Read(ext);

            var result = InvokeFileMetaAssoc(state, "-a " + args, true, ext);

            if (result != 0)
            {
                state.AddReport(String.Format("FileMetaAssoc -a failed for {0}", ext));
                pass = false;
            }

            if (pass)
            {
                var outcome = new RegState();
                outcome.Read(ext);

                // Verify that we got the final state
                if (outcome != final)
                {
                    state.AddReport(String.Format("Add did not produce the expected final registry state for {0}", ext));
                    pass = false;
                }
            }

            return(initial);
        }
Пример #2
0
        public static void Add(State state, string description, string name, string args, ref RegState final, ref bool pass, RegState?initial = null, bool noWipe = false)
        {
            state.AddReport(description);
            if (initial != null)
            {
                ((RegState)initial).Zap(Const.TestExt);
            }

            var result = InvokeFileMetaAssoc(state, "-a " + args);

            if (result != 0)
            {
                state.AddReport(String.Format("FileMetaAssoc -a failed for {0}", name));
                pass = false;
            }

            if (pass)
            {
                var outcome = new RegState();
                outcome.Read(Const.TestExt);

                // Verify that we got the final state
                if (outcome != final)
                {
                    state.AddReport(String.Format("Add did not produce the expected final registry state for {0}", name));
                    pass = false;
                }
            }

            // Clean up after ourselves
            if (!noWipe)
            {
                RegState.Wipe(Const.TestExt);
            }
        }
Пример #3
0
        private static bool VerifyRegistryState(string ext, ref RegState expected)
        {
            var outcome = new RegState();

            outcome.Read(Const.TestExt);

            // Verify that we got the final state
            return(outcome == expected);
        }
Пример #4
0
 private void scan_Click(object sender, RoutedEventArgs e)
 {
     // get all the current handlers
     using (RegistryKey handlers = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PropertySystem\PropertyHandlers", false))
     {
         foreach (string name in handlers.GetSubKeyNames())
         {
             using (RegistryKey key = handlers.OpenSubKey(name, false))
             {
                 string handlerGuid = (string)key.GetValue(null);
                 if (handlerGuid == Const.OurPropertyHandlerGuid)
                 {
                     RegState s = new RegState();
                     s.Read(name);
                     regStates.Add(name, s);
                 }
             }
         }
     }
 }
Пример #5
0
        public static void RemoveExtend(State state, string description, string ext, ref RegState final, ref bool pass)
        {
            state.AddReport(description);
            var result = InvokeFileMetaAssoc(state, "-r", true, ext);

            if (result != 0)
            {
                state.AddReport(String.Format("FileMetaAssoc -r failed for {0}", ext));
                pass = false;
            }

            var outcome = new RegState();

            outcome.Read(ext);

            // If the final state was specified, verify that we got it
            if (outcome != final)
            {
                state.AddReport(String.Format("Remove did not produce the expected final registry state for {0}", ext));
                pass = false;
            }
        }
Пример #6
0
        public static void Remove(State state, string description, string name, ref RegState source, ref bool pass, RegState?final = null)
        {
            state.AddReport(description);
            source.Zap(Const.TestExt);
            var result = InvokeFileMetaAssoc(state, "-r");

            if (result != 0)
            {
                state.AddReport(String.Format("FileMetaAssoc -r failed for {0}", name));
                pass = false;
            }

            var outcome = new RegState();

            outcome.Read(Const.TestExt);

            if (final == null)
            {
                // Usually, the expected final state is an empty registry
                if (outcome != new RegState())
                {
                    state.AddReport(String.Format("Remove did not completely clean up for {0}", name));
                    pass = false;
                }
            }
            else
            {
                // If the final state was specified, verify that we got it
                if (outcome != final)
                {
                    state.AddReport(String.Format("Remove did not produce the expected final registry state for {0}", name));
                    pass = false;
                }
            }

            // Clean up after ourselves
            RegState.Wipe(Const.TestExt);
        }
Пример #7
0
        private static void RoundTrip(State state, string name, ref RegState source, ref bool pass)
        {
            source.Zap(Const.TestExt);
            var read = new RegState();

            read.Read(Const.TestExt);
            if (read != source)
            {
                state.AddReport(String.Format("Round-trip failed for {0}", name));
                pass = false;
            }

            RegState.Wipe(Const.TestExt);

            var clear = new RegState();

            clear.Read(Const.TestExt);
            if (clear != new RegState())
            {
                state.AddReport(String.Format("Wipe failed for {0}", name));
                pass = false;
            }
        }