예제 #1
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);
            }
        }
예제 #2
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);
        }
예제 #3
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;
            }
        }
예제 #4
0
        public static void Run(Object obj)
        {
            State state = (State)obj;

            state.TestCounter = 1;
            bool overallPass = true;

            // Backup any saved state file because some add operations update it
            if (!Common.SetupProfileForTestRun(state))
            {
                return;
            }

            state.AddReport("");
            state.AddReport(String.Format("Run {0}", state.RunCounter));
            state.AddReport("");

            try
            {
                bool pass = true;
                RegState.Wipe(Const.TestExt); // Ensure that we start clean
                state.AddReport(String.Format("#{0}: Add a handler with Simple profile for the minimal extension {1}, then remove it again", state.TestCounter, Const.TestExt));

                RegState.CreateMinimalExtension(Const.TestExt);
                OpenAssociationManager(state);
                ScrollAndSelectExtension(state.extensions, Const.TestExt);
                SelectProfile(state.profiles, "Simple");
                state.addButton.GetInvokePattern().Invoke();
                CloseAssociationManager(state); // Need to do this before verifying the registry state as it seems to flush the changes through
                pass = VerifyRegistryState(Const.TestExt, ref Const.V15BuiltIn);

                if (!pass)
                {
                    state.AddReport(String.Format("Add did not produce the expected final registry state for {0}", Const.TestExt));
                }
                else
                {
                    OpenAssociationManager(state);
                    ScrollAndSelectExtension(state.extensions, Const.TestExt);
                    state.removeButton.GetInvokePattern().Invoke();
                    CloseAssociationManager(state);
                    var clear = new RegState();
                    pass = VerifyRegistryState(Const.TestExt, ref clear);
                    if (!pass)
                    {
                        state.AddReport(String.Format("Remove did not produce the expected final registry state for {0}", Const.TestExt));
                    }
                }

                RegState.Wipe(Const.TestExt);

                state.AddReport(String.Format("#{0}: {1}", state.TestCounter++, pass ? "Passed" : "Failed"));
                overallPass &= pass;

                pass = true;

                state.AddReport(String.Format("#{0}: Extend a handler for {1} with Tiny profile, then remove it again", state.TestCounter, Const.TestExt));

                Const.V15UnExtendedTiny.Zap(Const.TestExt);
                OpenAssociationManager(state);
                ScrollAndSelectExtension(state.extensions, Const.TestExt);
                SelectProfile(state.profiles, "tiny");
                state.addButton.GetInvokePattern().Invoke();
                DismissDialog(state.mainWindow, "Handler addition", "Yes");
                CloseAssociationManager(state);
                pass = VerifyRegistryState(Const.TestExt, ref Const.V15ExtendedTiny);

                if (!pass)
                {
                    state.AddReport(String.Format("Add did not produce the expected final registry state for {0}", Const.TestExt));
                }
                else
                {
                    // Check that saved state is as expected
                    pass = VerifySavedState("SavedStatePlus.xml");
                    if (!pass)
                    {
                        state.AddReport(String.Format("Add did not produce the expected saved state file for {0}", Const.TestExt));
                    }
                    else
                    {
                        OpenAssociationManager(state);
                        ScrollAndSelectExtension(state.extensions, Const.TestExt);
                        state.removeButton.GetInvokePattern().Invoke();
                        CloseAssociationManager(state);
                        pass = VerifyRegistryState(Const.TestExt, ref Const.V15UnExtendedTiny);
                        if (!pass)
                        {
                            state.AddReport(String.Format("Remove did not produce the expected final registry state for {0}", Const.TestExt));
                        }
                    }
                }

                RegState.Wipe(Const.TestExt);

                state.AddReport(String.Format("#{0}: {1}", state.TestCounter++, pass ? "Passed" : "Failed"));
                overallPass &= pass;
                pass         = true;

                state.AddReport(String.Format("#{0}: Set up a 1.3 handler for extension {1}, and verify that it is upgraded correctly", state.TestCounter, Const.TestExt));

                var result = MessageBox.Show(
                    "This test presses the Update Registry button, which updates all File Meta registry entries, as well as the test target. Are you happy to run this test?",
                    "Do you want to run this one?", MessageBoxButton.YesNo);

                if (result == MessageBoxResult.Yes)
                {
                    Const.V13BuiltIn.Zap(Const.TestExt);
                    OpenAssociationManager(state);
                    state.updateButton.GetInvokePattern().Invoke();
                    CloseAssociationManager(state); // Need to do this before verifying the registry state as it seems to flush the changes through
                    pass = VerifyRegistryState(Const.TestExt, ref Const.V15BuiltIn);

                    if (!pass)
                    {
                        state.AddReport(String.Format("Upgrade did not produce the expected final registry state for {0}", Const.TestExt));
                    }

                    RegState.Wipe(Const.TestExt);

                    state.AddReport(String.Format("#{0}: {1}", state.TestCounter++, pass ? "Passed" : "Failed"));
                    overallPass &= pass;
                }
                else
                {
                    state.AddReport(String.Format("#{0}: {1}", state.TestCounter++, "Skipped"));
                }

                RegState.Wipe(Const.TestExt);
            }
            catch (Exception ex)
            {
                state.AddReport(String.Format("Run failed with unexpected exception '{0}'", ex.Message));
            }
            finally
            {
                RegState.Wipe(Const.TestExt);
                Common.RestoreProfileAfterTestRun(state);
            }

            state.AddReport("");
            state.AddReport(String.Format("Run {0} completed {1}", state.RunCounter++, overallPass ? "with no failures" : "with some failures"));
        }