Exemple #1
0
        /* void GetAllDLLPath()
         * Get the dll path from framework config file.
         */
        private static void GetAllDllPath()
        {
            if (String.IsNullOrEmpty(_testObjPoolDLL))
            {
                try
                {
                    AutoConfig config = AutoConfig.GetInstance();

                    string domain = config.ProjectDomain;

                    string currentPath = Application.StartupPath;// Assembly.GetExecutingAssembly().Location;
                    currentPath = Path.GetDirectoryName(currentPath);

                    PluginInfo tmp = config.GetTestPluginByDomain(domain);

                    _testAppDLL       = tmp._testAppDLL;
                    _testAppClassName = tmp._testApp;

                    _testBrowserDLL       = tmp._testBrowserDLL;
                    _testBrowserClassName = tmp._testBrowser;

                    _testObjPoolDLL          = tmp._testObjectPoolDLL;
                    _testObjectPoolClassName = tmp._testObjectPool;

                    _testActionDLL       = tmp._testActionDLL;
                    _testActionClassName = tmp._testAction;

                    _testVPDLL       = tmp._testVPDLL;
                    _testVPClassName = tmp._testVP;

                    //default , we think it is web application.
                    _appType = 1;

                    bool isApp = false;

                    //if the <TestApp> text in config file is not empty, we think it is desktop application.
                    if (!String.IsNullOrEmpty(_testAppDLL))
                    {
                        _appType = 2;
                        isApp    = true;
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(_testBrowserDLL))
                        {
                            _appType = 0;

                            throw new CannotLoadDllException(" Test app and Test browser can not be null.");
                        }
                    }

                    bool allFound = true;

                    //search each dll
                    if (isApp)
                    {
                        if (!SearchDll(currentPath, ref _testAppDLL))
                        {
                            allFound = false;
                        }
                    }
                    else
                    {
                        if (!SearchDll(currentPath, ref _testBrowserDLL))
                        {
                            allFound = false;
                        }
                    }

                    if (!SearchDll(currentPath, ref _testObjPoolDLL))
                    {
                        allFound = false;
                    }

                    if (!SearchDll(currentPath, ref _testActionDLL))
                    {
                        allFound = false;
                    }

                    if (!SearchDll(currentPath, ref _testVPDLL))
                    {
                        allFound = false;
                    }

                    if (!allFound)
                    {
                        throw new CannotLoadDllException("Can not find the plugin dll.");
                    }
                }
                catch (TestException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    throw new CannotLoadDllException("Can not find the dll path: " + ex.ToString());
                }
            }
        }
Exemple #2
0
        /* void ParseFrameworkConfigFile(string frameworkConfigFile)
         * Parse framework config file.
         * NEED UPDATE!!!
         */
        private void ParseFrameworkConfigFile(string frameworkConfigFile)
        {
            if (String.IsNullOrEmpty(frameworkConfigFile) || !File.Exists(frameworkConfigFile))
            {
                throw new ConfigFileNotFoundException("Can not find framework config file:" + frameworkConfigFile);
            }

            _myFrameworkReader.Read();

            while (!_myFrameworkReader.EOF)
            {
                if (_myFrameworkReader.Name == "AutoTester" && !_myFrameworkReader.IsStartElement())
                {
                    break;
                }

                if (_myFrameworkReader.Name != "TestExtension")
                {
                    _myFrameworkReader.Read();
                }
                else
                {
                    try
                    {
                        PluginInfo tmp = new PluginInfo();

                        _myFrameworkReader.Read();

                        tmp._domain = _myFrameworkReader.ReadElementString("TestDomain");

                        tmp._testApp    = _myFrameworkReader.GetAttribute("ClassName");
                        tmp._testAppDLL = _myFrameworkReader.ReadElementString("TestApp");

                        tmp._testBrowser    = _myFrameworkReader.GetAttribute("ClassName");
                        tmp._testBrowserDLL = _myFrameworkReader.ReadElementString("TestBrowser");

                        tmp._testObjectPool    = _myFrameworkReader.GetAttribute("ClassName");
                        tmp._testObjectPoolDLL = _myFrameworkReader.ReadElementString("TestObjectPool");

                        tmp._testAction    = _myFrameworkReader.GetAttribute("ClassName");
                        tmp._testActionDLL = _myFrameworkReader.ReadElementString("TestAction");

                        tmp._testVP    = _myFrameworkReader.GetAttribute("ClassName");
                        tmp._testVPDLL = _myFrameworkReader.ReadElementString("TestVP");

                        _plugList.Add(tmp);

                        _myFrameworkReader.Read();

                        if (_myFrameworkReader.Name != "TestExtension")
                        {
                            break;
                        }
                    }
                    catch
                    {
                        throw new BadFormatConfigFileException("Invalid framework config file.");
                    }
                }

                continue;
            }

            _myFrameworkReader.Close();
        }