Example #1
0
 private static void Substitute(DataLayer.Test test)
 {
     foreach (Step step in test.Steps)
     {
         Substitute(test.Name, step);
     }
 }
Example #2
0
            public static void Load(DataLayer.Test test, UUTTestMode mode)
#endif
            {
                if (test == null)
                {
                    throw new ArgumentNullException("test", "A valid Test must be provided.");
                }
                if ((string.IsNullOrEmpty(test.Name) || manager.activeTests.ContainsKey(test.Name)))
                {
                    throw new ArgumentNullException("Test.Name", "An ActiveTest must have a unique name.");
                }

#if UUT_TEST == false
                manager.activeTests.Add(test.Name, new ActiveTest(test));
#else
                manager.activeTests.Add(test.Name, new ActiveTest(test, mode));
#endif
                manager.activeTests[test.Name].Start(manager.priority++);

                ActiveTest aTest = manager.activeTests[test.Name];
                while ((!aTest.IsInState(aTest.m_StateEnded)) && (!aTest.IsInState(aTest.m_StateLoaded)))
                {
                    System.Threading.Thread.Sleep(1);
                }
            }
Example #3
0
        private static void Bind(DataLayer.Test test, string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                path = Environment.CurrentDirectory;
            }
            else if (!Directory.Exists(path))
            {
                throw new ArgumentException("Path " + path + " does not exist.", "path");
            }

            DirectoryInfo directories = new DirectoryInfo(path);

            FileInfo[] files = directories.GetFiles("*.dll").Where(f => f.Name.StartsWith("TruePosition.Test.Custom")).ToArray();

            foreach (FileInfo info in files)
            {
                try
                {
                    Assembly.LoadFile(info.FullName);
                }
                catch (Exception ex) { }
            }

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                ResponseProcessor.BindEvents(test, assembly);
            }
        }
Example #4
0
        public static void Save(this DataLayer.Test test, string destinationPath)
        {
            if (!Directory.Exists(destinationPath))
            {
                Directory.CreateDirectory(destinationPath);
            }

            Save(destinationPath, test.Filename(), test);
        }
Example #5
0
        private void Initialize(DataLayer.Test test)
        {
            Name = test.Name;
            Test = test;

            m_StateLoaded   = new QState(ActiveTest_Loaded);
            m_StateRunning  = new QState(ActiveTest_Running);
            m_StateStepping = new QState(ActiveTest_Stepping);
            m_StatePassed   = new QState(ActiveTest_Passed);
            m_StateFailed   = new QState(ActiveTest_Failed);
            m_StateAborted  = new QState(ActiveTest_Aborted);
            m_StateEnded    = new QState(ActiveTest_Ended);

            TimeoutTimer = new QTimer(this);
        }
Example #6
0
        private static DataLayer.Test HydrateTest(XElement xmlTest)
        {
            DataLayer.Test test = new DataLayer.Test(xmlTest.Attribute("Name").Value);

            try
            {
                test.Steps = HydrateSteps(xmlTest.Descendants(Namespace + "Step"));
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Error in XML. " + ex.Message + " Test " + test.Name + (test.Steps == null ? "" : ", step #" + (test.Steps.Count + 1)) + ".");
            }

            return(test);
        }
Example #7
0
            public static void Load(string uutName, string responseFilePath, DataLayer.Test test, UUTTestMode mode)
            {
                if (test == null)
                {
                    throw new ArgumentNullException("test", "A valid Test must be provided.");
                }
                if ((string.IsNullOrEmpty(uutName) || manager.activeUUTs.ContainsKey(uutName)))
                {
                    throw new ArgumentNullException("Test.Name", "An ActiveUUT must have a unique name.");
                }

                manager.activeUUTs.Add(uutName, new ActiveUUT(uutName, responseFilePath, test, mode));
                manager.activeUUTs[uutName].Start(manager.priority++);

                ActiveUUT aUUT = manager.activeUUTs[uutName];

                while ((!aUUT.IsInState(aUUT.m_StateEnded)) && (!aUUT.IsInState(aUUT.m_StateLoaded)))
                {
                    System.Threading.Thread.Sleep(1);
                }
            }
Example #8
0
        private static void Unload(DataLayer.Test test, IEnumerable <Actor> actors)
        {
            foreach (Actor actor in actors)
            {
                switch (actor.Type)
                {
                case ActorType.Port:
                    QFManager.Port.Close(actor.Name);
                    break;

                case ActorType.Process:
                    QFManager.Process.Kill(actor.Name);
                    break;

                case ActorType.Prompt:
                    break;

                case ActorType.Recorder:
                    QFManager.Recorder.Close(actor.Name);
                    break;

                default:
                    throw new NotImplementedException();
                }
            }

            try
            {
                QFManager.Test.End(test.Name);
                Debug.Print("<Event=Test successfully unloaded,\tTest=" + test.Name + ">");
                if (TestUnloaded != null)
                {
                    TestUnloaded.BeginInvoke(null, new TestUnloadedEventArgs(test.Name), null, null);
                }
            }
            catch (Exception ex)
            {
                QFManager.Test.Abort(test.Name, ex.Message);
            }
        }
Example #9
0
        public static void Run(DataLayer.Test test, IHandlerTarget handlerTarget, string configPath, string binaryPath, UUTTestMode mode)
#endif
        {
            if (test == null)
            {
                throw new ArgumentNullException("test", "A valid test must be provided.");
            }
            if ((test.Steps == null) || (test.Steps.Count == 0))
            {
                throw new ArgumentNullException("test.Steps", "A test must contain one or more Steps.");
            }

            IEnumerable <Actor> actors = test.Steps.Distinct(new StepComparer()).Select(s => s.Actor);

            if (actors == null)
            {
                throw new InvalidOperationException("Test " + test.Name + " yielded no meaningful actions.");
            }

            lock (thisLock)
            {
#if UUT_TEST == false
                Load(test, actors, handlerTarget, configPath);
#else
                Load(test, actors, handlerTarget, configPath, mode);
#endif
                Bind(test, binaryPath);
                Substitute(test);
                Run(test, actors);
                ThreadPool.RegisterWaitForSingleObject(testComplete,
                                                       (state, timedOut) =>
                {
                    Unload(test, actors);
                },
                                                       null, -1, true);
            }
        }
Example #10
0
        private static void Run(DataLayer.Test test, IEnumerable <Actor> actors)
        {
            foreach (Actor actor in actors)
            {
                switch (actor.Type)
                {
                case ActorType.Port:
                    QFManager.Port.Open(actor.Name);
                    break;

                case ActorType.Process:
                case ActorType.Prompt:
                case ActorType.Recorder:
                    // DESIGN NOTE:
                    // There is no 'implicit' pre-Run action for these actors...
                    break;

                default:
                    throw new NotImplementedException();
                }
            }

            QFManager.Test.Run(test.Name);
        }
Example #11
0
        //private string[] responses = { "ESN: " + "\r\n" +
        //                              "GBE_CTLR:     NOT INSTALLED            " + "\r\n" +
        //                              "GBE_LNA:      NOT INSTALLED            " + "\r\n" +
        //                              "GBE:          NOT INSTALLED            " + "\r\n" +
        //                              "GBE CUST ESN: NOT INSTALLED            " + "\r\n" +
        //                              "LMU:          06162200D010082006501DA6 " + "\r\n" +
        //                              "GPS RCVR:     06162200D010082006501DA6 " + "\r\n" +
        //                              "RECEIVER:     06163900B0100820070403C2 " + "\r\n" +
        //                              "BDC:          06164000C11008200704063B " + "\r\n" +
        //                              "PSUPPLY:      06163400G0100820064300C1 " + "\r\n" +
        //                              "CP/DSP:       06164100B1100820064700C2 " + "\r\n" +
        //                              "DCARD:        06160301B010082006440005 " + "\r\n" +
        //                              "EBOARD:       NOT INSTALLED            " + "\r\n" +
        //                              "CUSTESN:      TRULMU5207872AE          " + "\r\n" +
        //                              "TEMPERATURES: recvr 31 bdc 28 power supply 35" + "\r\n" +
        //                              "TPESN:        06630000D010082007050130" + "\r\n" +
        //                              "LMU>\r\n"};

        public ActiveUUT(string uutName, string responseFilePath, string testCollectionName, DataLayer.Test test, UUTTestMode mode)
            : base(test, mode)
        {
            Name             = uutName;
            TestSetName      = testCollectionName;
            ResponseFilePath = responseFilePath;

            qf4net.QF.Instance.Subscribe(this, (int)QFSignal.TestStep);
            qf4net.QF.Instance.Subscribe(this, (int)QFSignal.TestResult);
        }
Example #12
0
        private static void Load(DataLayer.Test test, IEnumerable <Actor> actors, IHandlerTarget handlerTarget, string configPath, UUTTestMode mode)
#endif
        {
            if (!string.IsNullOrEmpty(configPath))
            {
                ConfigManager.SetLocation(configPath);
            }

            foreach (Actor actor in actors)
            {
                switch (actor.Type)
                {
                case ActorType.Port:
                    QFManager.Port.Create((PortType)Enum.Parse(typeof(PortType), actor.SubType), ConfigManager.ReadStream(actor.Name));
                    QFManager.Port.Receive(actor.Name, PortDataReceived);
                    QFManager.Port.Error(actor.Name, PortError);
                    QFManager.Port.ReceiveTimeout(actor.Name, PortReceiveTimeoutExpired);
                    if (handlerTarget != null)
                    {
                        QFManager.Port.Receive(actor.Name, handlerTarget.PortReceive);
                        QFManager.Port.ReceiveTimeout(actor.Name, handlerTarget.PortTimeout);
                        QFManager.Port.Error(actor.Name, handlerTarget.PortError);
                    }
                    break;

                case ActorType.Process:
                    QFManager.Process.Create(ConfigManager.ReadStream(actor.Name));
                    QFManager.Process.Launched(actor.Name, ProcessLaunched);
                    QFManager.Process.Killed(actor.Name, ProcessKilled);
                    QFManager.Process.Timeout(actor.Name, ProcessTimeout);
                    QFManager.Process.Error(actor.Name, ProcessError);
                    if (handlerTarget != null)
                    {
                        QFManager.Process.Launched(actor.Name, handlerTarget.ProcessLaunched);
                        QFManager.Process.Killed(actor.Name, handlerTarget.ProcessKilled);
                        QFManager.Process.Timeout(actor.Name, handlerTarget.ProcessTimeout);
                        QFManager.Process.Error(actor.Name, handlerTarget.ProcessError);
                    }
                    break;

                case ActorType.Prompt:
                    QFManager.Prompt.Create(actor.Name);
                    QFManager.Prompt.Showing(actor.Name, PromptShowing);
                    QFManager.Prompt.Closed(actor.Name, PromptClosed);
                    QFManager.Prompt.Error(actor.Name, PromptError);
                    if (handlerTarget != null)
                    {
                        QFManager.Prompt.Showing(actor.Name, handlerTarget.PromptShowing);
                        QFManager.Prompt.Closed(actor.Name, handlerTarget.PromptClosed);
                        QFManager.Prompt.Error(actor.Name, handlerTarget.PromptError);
                    }
                    break;

                case ActorType.Recorder:
                    QFManager.Recorder.Create(RecorderType.File, actor.Name);
                    QFManager.Recorder.Opening(actor.Name, RecorderOpening);
                    QFManager.Recorder.Opened(actor.Name, RecorderOpened);
                    QFManager.Recorder.Recording(actor.Name, RecorderRecording);
                    QFManager.Recorder.Closed(actor.Name, RecorderClosed);
                    QFManager.Recorder.Error(actor.Name, RecorderError);
                    if (handlerTarget != null)
                    {
                        QFManager.Recorder.Opened(actor.Name, handlerTarget.RecorderOpened);
                        QFManager.Recorder.Recording(actor.Name, handlerTarget.RecorderRecording);
                        QFManager.Recorder.Closed(actor.Name, handlerTarget.RecorderClosed);
                        QFManager.Recorder.Error(actor.Name, handlerTarget.RecorderError);
                    }
                    break;

                default:
                    throw new NotImplementedException();
                }
            }

#if UUT_TEST == false
            QFManager.Test.Load(test);
#else
            QFManager.Test.Load(test, mode);
#endif

            QFManager.Test.Stepping(test.Name, TestStepping);
            QFManager.Test.Error(test.Name, TestError);
            QFManager.Test.Stepped(test.Name, TestStepped);
            QFManager.Test.Passed(test.Name, TestPassed);
            QFManager.Test.Failed(test.Name, TestFailed);
            QFManager.Test.Aborted(test.Name, TestAborted);
            if (handlerTarget != null)
            {
                QFManager.Test.Stepping(test.Name, handlerTarget.TestStepping);
                QFManager.Test.Error(test.Name, handlerTarget.TestError);
                QFManager.Test.Stepped(test.Name, handlerTarget.TestStepped);
                QFManager.Test.Aborted(test.Name, handlerTarget.TestAborted);
                QFManager.Test.Passed(test.Name, handlerTarget.TestPassed);
                QFManager.Test.Failed(test.Name, handlerTarget.TestFailed);
                if (TestUnloaded == null)
                {
                    TestUnloaded += handlerTarget.TestUnloaded;
                }
            }
        }
Example #13
0
 public static void Load(DataLayer.Test test)
 {
     Load(test, UUTTestMode.Port);
 }
Example #14
0
 public ActiveTest(DataLayer.Test test) : base()
 {
     Initialize(test);
 }
Example #15
0
 public static void Run(DataLayer.Test test, UUTTestMode mode)
 {
     Run(test, null, mode);
 }
Example #16
0
 public static string Filename(this DataLayer.Test test)
 {
     return(test.Name.Split(Path.GetInvalidFileNameChars(),
                            StringSplitOptions.RemoveEmptyEntries).Aggregate((agg, n) => agg + n) + ".xml");
 }
Example #17
0
 public ActiveTest(DataLayer.Test test, UUTTestMode mode)
     : base()
 {
     Initialize(test);
     Mode = mode;
 }
Example #18
0
        /// <summary>
        /// Orchestrates the setup, asynchronous execution and teardown of a Test in the TQF
        /// </summary>
        /// <param name="test">Test to run</param>
        /// <param name="handlerTarget">Target for all ActiveObject events</param>
        /// <param name="path">path location of custom script binaries</param>
#if UUT_TEST == false
        public static void Run(DataLayer.Test test, IHandlerTarget handlerTarget, string configPath, string binaryPath)
Example #19
0
 private static IEnumerable <XElement> DehydrateSteps(DataLayer.Test test)
 {
     return(from step in test.Steps
            select DehydrateStep(step));
 }
Example #20
0
 public static void Run(DataLayer.Test test, IHandlerTarget handlerTarget, string configPath, UUTTestMode mode)
 {
     Run(test, handlerTarget, configPath, string.Empty, mode);
 }
Example #21
0
        /// <summary>
        /// Orchestrates the setup, asynchronous execution and teardown of a Test in the TQF
        /// </summary>
        /// <param name="test">Test to run</param>
        /// <param name="handlerTarget">Target for all ActiveObject events</param>
#if UUT_TEST == false
        public static void Run(DataLayer.Test test, IHandlerTarget handlerTarget, string configPath)
        {
            Run(test, handlerTarget, configPath, string.Empty);
        }
Example #22
0
        /// <summary>
        /// Orchestrates the setup, asynchronous execution and teardown of a Test in the TQF
        /// </summary>
        /// <param name="test">Test to run</param>
        /// <param name="handlerTarget">Target for all ActiveObject events</param>
#if UUT_TEST == false
        public static void Run(DataLayer.Test test, IHandlerTarget handlerTarget)
        {
            Run(test, handlerTarget, string.Empty, string.Empty);
        }
Example #23
0
 public ActiveUUT(string uutName, string responseFilePath, DataLayer.Test test, UUTTestMode mode)
     : this(uutName, responseFilePath, null, test, mode)
 {
 }
Example #24
0
        private static void Save(string destinationPath, string filename, DataLayer.Test test)
        {
            XElement testXml = Dehydrator.Dehydrate(test);

            testXml.Save(Path.Combine(destinationPath, filename));
        }
Example #25
0
 public ActiveTest(DataLayer.Test test) : this(test, UUTTestMode.Port)
 {
 }
Example #26
0
 /// <summary>
 /// Abort the given Test and initiaite teardown
 /// </summary>
 /// <param name="test">Test to abort</param>
 /// <param name="reason">abort reason</param>
 public static void Abort(DataLayer.Test test, string reason)
 {
     QFManager.Test.Abort(test.Name, reason);
 }
Example #27
0
 private static void Load(DataLayer.Test test, IEnumerable <Actor> actors, IHandlerTarget handlerTarget, string configPath)
Example #28
0
 public static void Load(DataLayer.Test test)
Example #29
0
 private static XElement DehydrateTest(DataLayer.Test test)
 {
     return(new XElement("Test",
                         new XAttribute("Name", test.Name),
                         DehydrateSteps(test)));
 }
Example #30
0
        /// <summary>
        /// Orchestrates the setup, asynchronous execution and teardown of a Test in the TQF
        /// </summary>
        /// <param name="test">Test to run</param>
#if UUT_TEST == false
        public static void Run(DataLayer.Test test)
        {
            Run(test, null, string.Empty, string.Empty);
        }