示例#1
0
        /*
         * If call to sendDmIcdPacketEx was successful, export text from Item View into a store file
         */
        public static bool Teardown(AutomationWindow window)
        {
            if (sentPacket && response.Length > 0)
            {
                // Get path to export to (current working directory)
                string storeFilePath = Program.GetWorkingDirectory();
                if (storeFilePath == "")
                {
                    return(false);
                }

                storeFilePath += "ExportViewTextWithComTest.txt";

                // Export Item View text to store file
                uint success = window.ExportViewText("Item View", storeFilePath);

                if (success == 0)
                {
                    Console.WriteLine("Unable to export items, 'Item View'");
                    Console.WriteLine("Last error string: " + window.GetLastErrorString());
                    return(false);
                }

                Console.WriteLine("Items exported to item store file: " + storeFilePath);
                return(true);
            }
            else
            {
                Console.WriteLine("Problem writing or retrieving packet");
                Console.WriteLine("Last error string: " + window.GetLastErrorString());
                return(false);
            }
        }
示例#2
0
        public static bool Teardown(AutomationWindow window)
        {
            bool result;

            result = window.ClearViewItems("Item View");
            if (result == false)
            {
                Console.WriteLine("Error ClearViewItems: " + window.GetLastErrorString());
            }

            return(result);
        }
示例#3
0
        public static bool Setup(AutomationWindow window)
        {
            bool result;
            uint autoResult;

            result = window.LoadConfig(Program.GetWorkingDirectory() + "simple.dmc");
            if (result == true)
            {
                autoResult = window.CloseView("Item View", null);
                Console.WriteLine("Close Itemview, result = " + autoResult);

                autoResult = window.CreateView("Item View", "");
                Console.WriteLine("Create Itemview, result = " + autoResult);
            }
            else
            {
                Console.WriteLine("Load Config Error:" + window.GetLastErrorString());
            }

            return(result);
        }
示例#4
0
        static bool RunTestCase(QXDMAutomation.TestCase testCase, string functionName, AutomationWindow automationWindow, uint port)
        {
            bool usesComPort = testCase._requiresComPort;

            // Print to log
            string msg = "< RUNNING TEST CASE: " + functionName.ToUpper() + " >";

            LogEverywhere("");

            for (int i = 0; i < msg.Length; i++)
            {
                Console.Write("\\");
                logFile.Write("\\");
            }
            LogEverywhere("\n" + msg);

            string errorMessage   = "\t[ERROR] Test case \"" + functionName + "\" failed: ";
            string successMessage = "\t[PASS] Test case \"" + functionName + "\" succeeded";

            // Run setup function
            if (testCase._setup != null && testCase._setup(automationWindow) == false)
            {
                logFile.WriteLine(errorMessage + "Setup function failed");
                return(false);
            }

            // Set up COM stuff if needed
            if (usesComPort == true)
            {
                if (port != 0)
                {
                    if (automationWindow.SetComPort(port) == true)
                    {
                        if (automationWindow.GetServerState() == 2)
                        {
                            Console.WriteLine("Connected to port: {0}", port);
                        }
                        else
                        {
                            logFile.WriteLine(errorMessage + "Error connecting to port: " + port);
                            return(false);
                        }
                    }
                    else
                    {
                        logFile.WriteLine(errorMessage + "SetComPort Failed - port: " + port + " message: " + automationWindow.GetLastErrorString());
                        return(false);
                    }
                }
                else
                {
                    logFile.WriteLine(errorMessage + "Requires a connection");
                    return(false);
                }
            }

            // Run exec function
            if (testCase._exec != null && testCase._exec(automationWindow) == false)
            {
                logFile.WriteLine(errorMessage + "Exec function failed");
                return(false);
            }

            // Disconnect the port if in use
            if (usesComPort == true)
            {
                automationWindow.SetComPort(0);
            }

            // Run teardown (cleanup) function
            if (testCase._teardown != null && testCase._teardown(automationWindow) == false)
            {
                logFile.WriteLine(errorMessage + "Teardown function failed");
                return(false);
            }

            logFile.WriteLine(successMessage);
            return(true);
        }