Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DriverConnectionFactoryDescDeprecated"/> class.
 /// </summary>
 /// <param name="container">Resource container.</param>
 /// <param name="specification">The db specification.</param>
 public DriverConnectionFactoryDescDeprecated(
     IContainer container,
     DriverConfiguration specification)
 {
     _driver            = ResolveDriverFromName(container, specification.DriverName);
     _driver.Properties = specification.Properties;
 }
Esempio n. 2
0
        public Driver(string path, DriverConfiguration configuration)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(Path));
            }

            if (string.IsNullOrEmpty(configuration.Secret))
            {
                throw new ArgumentNullException(nameof(Secret));
            }

            if (string.IsNullOrEmpty(configuration.Bytes))
            {
                throw new ArgumentNullException(nameof(DriverContent.Bytes));
            }

            if (configuration.Expiry < 5000 || configuration.Expiry > 15000)
            {
                throw new ArgumentException("Expiry must be between 5000 and 15 000");
            }

            this.Path          = path;
            this.Pid           = configuration.Pid;
            this.Name          = configuration.Name;
            this.Secret        = configuration.Secret;
            this.DriverContent = new DriverContent()
            {
                Bytes = configuration.Bytes
            };
            this.Expiry = configuration.Expiry;
        }
Esempio n. 3
0
        private void SetServiceMissingParams()
        {
            ObservableList <PluginPackage>  Plugins  = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <PluginPackage>();
            IEnumerable <PluginServiceInfo> Services = Plugins.SelectMany(x => x.Services);
            PluginServiceInfo PSI = Services.Where(x => x.ServiceId == ServiceId).FirstOrDefault();

            PluginPackage PP = Plugins.Where(x => x.Services.Contains(PSI)).First();

            PP.LoadServicesFromJSON();
            PSI = PP.Services.Where(x => x.ServiceId == ServiceId).FirstOrDefault();

            foreach (var config in PSI.Configs)
            {
                if (DriverConfiguration.Where(x => x.Parameter == config.Name).Count() == 0)
                {
                    DriverConfigParam DI = new DriverConfigParam();
                    DI.Parameter      = config.Name;
                    DI.Value          = config.DefaultValue;
                    DI.Description    = config.Description;
                    DI.OptionalValues = config.OptionalValues;
                    DI.Type           = config.Type;
                    DriverConfiguration.Add(DI);
                }
            }

            SetPlatformParameters(PSI);
        }
        public void Constructor_ConfigurationBuilder_BindReturnsInstance()
        {
            string currentDirectory = Directory.GetCurrentDirectory();
            string testsFolder      = currentDirectory.Substring(0, currentDirectory.IndexOf("bin"));

            IConfigurationRoot testConfig = new ConfigurationBuilder()
                                            .AddJsonFile($"{testsFolder}{Path.DirectorySeparatorChar}config.test.json", optional: false)
                                            .Build();

            DriverConfiguration driverConfiguration = new DriverConfiguration();

            testConfig.GetSection("DriverConfiguration").Bind(driverConfiguration);

            Assert.IsNotNull(driverConfiguration, "driverConfiguration");
            Assert.IsNotNull(driverConfiguration.Resilience, "driverConfiguration.Resilience");
            Assert.IsNotNull(driverConfiguration.Consensus, "driverConfiguration.Consensus");
            Assert.IsNotNull(driverConfiguration.Nodes, "driverConfiguration.Nodes");

            // Check default values
            Assert.IsTrue(driverConfiguration.Resilience.EnableCircuitBreaking, "driverConfiguration.Resilience.EnableCircuitBreaking");
            Assert.IsTrue(driverConfiguration.Resilience.EnableRetry, "driverConfiguration.Resilience.EnableRetry");
            Assert.AreEqual(Consensus.ModelType.FirstWins, driverConfiguration.Consensus.Model);
            Assert.AreEqual(1, driverConfiguration.Consensus.InAgreement);
            Assert.AreEqual(1, driverConfiguration.Nodes.Length);

            Node node = driverConfiguration.Nodes[0];

            Assert.AreEqual("test.node", node.Name);
            Assert.AreEqual(100, node.TimeoutInMilliseconds);
            Assert.AreEqual(new System.Uri("https://test.org"), node.Uri);
            Assert.AreEqual(Node.UseType.Always, node.Use);
            Assert.IsTrue(node.AllowCaching, "node.AllowCaching");
        }
Esempio n. 5
0
 protected override DriverConfiguration RegisterDrivers() => DriverConfiguration.Initialise
 (
     "JankWorks.Glfw",
     "JankWorks.DotNet",
     "JankWorks.FreeType",
     "JankWorks.OpenGL",
     "JankWorks.OpenAL"
 );
Esempio n. 6
0
        static void RefreshView()
        {
            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();

            var client = DriverConfiguration.Client;
            var db     = client.GetDatabase(DriverConfiguration.DatabaseNamespace.DatabaseName);

            IMongoCollection <ViewIP> categories = db.GetCollection <ViewIP>("levelIp");
            List <ViewIP>             list       = categories.Find(Builders <ViewIP> .Filter.Eq("view", "BaiSpi")).ToList <ViewIP>();

            var newMongoClientSettings = DriverConfiguration.GetClientSettings("mongodb://192.168.30.144:27017");
            var newClent = new MongoClient(newMongoClientSettings);
            var newDB    = newClent.GetDatabase("network");
            IMongoCollection <NewViewIPData> newCategories = newDB.GetCollection <NewViewIPData>("levelip");
            List <NewViewIPData>             newlist       = newCategories.Find(Builders <NewViewIPData> .Filter.Empty).ToList <NewViewIPData>();



            IMongoCollection <ViewIP> newCategories2 = db.GetCollection <ViewIP>("baispi");
            List <ViewIP>             vslist         = new List <ViewIP>();

            foreach (NewViewIPData nv in newlist)
            {
                ViewIP tempV = new ViewIP();
                tempV.start = Convert.ToInt64(nv.start);
                tempV.end   = Convert.ToInt64(nv.end);
                tempV.view  = "BaiSpi";
                tempV.level = 0;
                vslist.Add(tempV);
                //bool isMixed = false;
                //foreach (ViewIP v in list)
                //{
                //    if (Convert.ToInt64(nv.start) >= v.start && Convert.ToInt64(nv.start) <= v.end)
                //    {
                //        tempV = v;
                //        isMixed = true;
                //    }
                //    else if (Convert.ToInt64(nv.end) >= v.start && Convert.ToInt64(nv.end) <= v.end)
                //    {
                //        tempV = v;
                //        isMixed = true;
                //    }
                //}
                //if (isMixed)//有交集  更新
                //{
                //    Console.WriteLine(nv.network + " mixed");
                //}
                //else
                //{//无交集  添加
                //    Console.WriteLine(nv.network + " not mixed");

                //}
            }
            Console.WriteLine(vslist.Count);
            categories.InsertMany(vslist);
            watch.Stop();
        }
Esempio n. 7
0
 public void TearDown()
 {
     if (Server != null)
     {
         Server.Dispose();
         DriverConfiguration.ResetToDefaults();
     }
     AfterEachTest();
 }
        public static void ReadConfig()
        {
            if (Current != null)
            {
                throw new InvalidOperationException("Context is already initialized");
            }

            Current = new WebDriverContext(DriverConfiguration.GetConfiguration(), EnvironmentsConfiguration.GetConfiguration());
        }
Esempio n. 9
0
 public void SetUp()
 {
     Trigger = new AutoResetEvent(false);
     if (NeedAServer)
     {
         Server = new FakeServer();
         DriverConfiguration.Configuration(c => c.ConnectTo("http://localhost:" + FakeServer.Port + "/"));
     }
     BeforeEachTest();
 }
Esempio n. 10
0
        public void Setup()
        {
            var driverConfig = new DriverConfiguration()
                               .Bind();

            driverWrapper      = new DriverWrapper(new ChromeDriver(driverConfig.DriverPath), driverConfig);
            highliter          = new Highliter(driverWrapper);
            webElementComposer = new WebElementComposer(driverWrapper, highliter);
            wait = new Wait(new WebDriverWait(driverWrapper.Driver, TimeSpan.FromSeconds(driverConfig.DefaultTimeout)), webElementComposer);
        }
Esempio n. 11
0
        /// <summary>
        /// Set AGent Configuration with default values in addition to the configurations asked by Service
        /// </summary>
        /// <param name="PSI"></param>
        private void SetPlatformParameters(PluginServiceInfo PSI)
        {
            if (PSI.Interfaces.Where(x => x == "IWebPlatform").Count() > 0)
            {
                DriverConfigParam DI = new DriverConfigParam();
                DI.Parameter   = "Max Agent Load Time";
                DI.Value       = "30";
                DI.Description = "Max Time allowed in seconds to start the agent0";

                DI.IsPlatformParameter = true;

                DriverConfiguration.Add(DI);


                DriverConfigParam DI2 = new DriverConfigParam();
                DI2.Parameter   = "Auto Switch Frame";
                DI2.Value       = bool.TrueString;
                DI2.Description = "Automatic Switch Frame for POM Element";

                DI2.IsPlatformParameter = true;

                DriverConfiguration.Add(DI2);
            }
            else if (PSI.Interfaces.Where(x => x == "IWebServicePlatform").Count() > 0)
            {
                DriverConfigParam DI = new DriverConfigParam();
                DI.Parameter   = "Save Request";
                DI.Value       = bool.FalseString;
                DI.Description = "Save Request";

                DI.IsPlatformParameter = true;

                DriverConfiguration.Add(DI);


                DriverConfigParam DI2 = new DriverConfigParam();
                DI2.Parameter   = "Save Response";
                DI2.Value       = bool.TrueString;
                DI2.Description = "Save Response";

                DI2.IsPlatformParameter = true;

                DriverConfiguration.Add(DI2);


                DriverConfigParam DI3 = new DriverConfigParam();
                DI3.Parameter   = "Path To Save";
                DI3.Value       = @"~\Documents";
                DI3.Description = "Path to Save Request/Response Files";

                DI3.IsPlatformParameter = true;

                DriverConfiguration.Add(DI3);
            }
        }
 public void SetUp()
 {
     DriverConfiguration configuration = new DriverConfiguration();
     var options = new PhantomJSOptions();
     options.AddAdditionalCapability("phantomjs.page.settings.UserAgent", "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X;en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4Mobile/7B334b Safari/531.21.10 ");
     var services = PhantomJSDriverService.CreateDefaultService();
     services.LogFile = "D:\\AutomationReport\\Log.txt";
     configuration.DriverServices = services;
     configuration.DesiredCapabilities = options;
     DriverManager.StartDriver(Browser.PhantomJSBrowser,configuration);
 }
 public void WontTryToConnectIfNetworkCheckReturnsFalse()
 {
     DriverConfiguration.Configuration(c => c.NetworkAvailableCheck(() => false));
     new Communicator(FakeContext.Defaults).SendPayload <object>("PUT", "anything", null, s =>
     {
         Assert.AreEqual("Network is not available", s.Error.Message);
         Assert.AreEqual(false, s.Success);
         Set();
     });
     WaitOne();
 }
Esempio n. 14
0
        public WeatherHomePage(DriverConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            Driver = configuration.WebDriver;
            wait   = configuration.Wait;

            PageFactory.InitElements(Driver, this);
        }
        public void SetUp()
        {
            DriverConfiguration configuration = new DriverConfiguration();
            var options = new PhantomJSOptions();

            options.AddAdditionalCapability("phantomjs.page.settings.UserAgent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36");
            var services = PhantomJSDriverService.CreateDefaultService();

            services.LogFile                  = "D:\\AutomationReport\\Log.txt";
            configuration.DriverServices      = services;
            configuration.DesiredCapabilities = options;
            DriverManager.StartDriver(Browser.PhantomJSBrowser, configuration);
        }
        /// <summary>
        /// Called to create the virtual printer
        /// </summary>
        public void Create()
        {
            this.portCreated = false;

            DriverConfiguration driverConfig = this.configuration.DriverConfiguration;

            if (!this.printerSupport.PrintDriverExists(driverConfig.Name))
            {
                this.printerSupport.AddPrintDriver(
                    driverConfig.ConfigFileName,
                    driverConfig.DataFileName,
                    driverConfig.DependentFileNames,
                    driverConfig.DriverFileName,
                    driverConfig.Name,
                    driverConfig.Environment,
                    driverConfig.HelpFileName);
            }

            bool create = !this.printerSupport.PortExists(this.configuration.DefaultPort);

            if (create)
            {
                this.printerSupport.AddPort(this.configuration.DefaultPort);
                this.portCreated = true;
            }

            this.currentPort = configuration.DefaultPort;

            create = !this.printerSupport.PrinterExists(this.configuration.PrinterName);

            if (create)
            {
                this.printerSupport.CreatePrinter(this.configuration.PrinterName,
                                                  this.configuration.DefaultPort,
                                                  driverConfig.Name,
                                                  this.configuration.PrintProcessor ?? WinProcessor);
            }
            else
            {
                this.portCreated = this.printerSupport.UpdatePort(
                    this.currentPort,
                    this.configuration.DefaultPort,
                    this.portCreated,
                    this.configuration.PrinterName);

                this.currentPort = this.configuration.DefaultPort;
            }

            // Flag the printer as being created so it gets removed when this instance shuts down
            this.printerCreated = true;
        }
Esempio n. 17
0
        public override void PostDeserialization()
        {
            if (DriverType == eDriverType.WindowsAutomation)
            {
                //Upgrading Action timeout for windows driver from default 10 secs to 30 secs
                DriverConfigParam actionTimeoutParameter = DriverConfiguration.Where(x => x.Parameter == nameof(DriverBase.ActionTimeout)).FirstOrDefault();

                if (actionTimeoutParameter != null && actionTimeoutParameter.Value == "10" && actionTimeoutParameter.Description.Contains("10"))
                {
                    actionTimeoutParameter.Value       = "30";
                    actionTimeoutParameter.Description = actionTimeoutParameter.Description.Replace("10", "30");
                }
            }
        }
        private IWebDriver CreateDriver()
        {
            IWebDriver webDriver;

            switch (_driverConfiguration.TargetDriver)
            {
            case DriverNames.IE:
                webDriver = new InternetExplorerDriver(new InternetExplorerOptions()
                {
                    IgnoreZoomLevel = true,
                    IntroduceInstabilityByIgnoringProtectedModeSettings = true
                });
                break;

            case DriverNames.Firefox:
                var firefoxProfile = new FirefoxProfile();
                firefoxProfile.AddExtension(@"JSErrorCollector.xpi");
                if (!String.IsNullOrEmpty(DriverConfiguration.GetConfiguration().DownloadDir))
                {
                    firefoxProfile.SetPreference("browser.download.dir", DriverConfiguration.GetConfiguration().DownloadDir);
                    firefoxProfile.SetPreference("browser.helperApps.alwaysAsk.force", false);
                    firefoxProfile.SetPreference("browser.download.folderList", 2);
                    firefoxProfile.SetPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false);
                    firefoxProfile.SetPreference("browser.download.useDownloadDir", true);
                    firefoxProfile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "image/png, application/vnd.ms-excel");
                }
                webDriver = new FirefoxDriver(firefoxProfile);
                break;

            case DriverNames.Chrome:
                webDriver = new OpenQA.Selenium.Chrome.ChromeDriver();
                break;

            case DriverNames.PhantomJS:
                var options = new PhantomJSOptions();
                options.AddAdditionalCapability("user-agent", PhantomUserAgent);
                webDriver = new PhantomJSDriver(options);
                break;

            case DriverNames.Safari:
                webDriver = new OpenQA.Selenium.Safari.SafariDriver();
                break;

            default:
                throw new NotImplementedException();
            }

            return(webDriver);
        }
        public void Constructor_ReturnsDefaultInstance()
        {
            DriverConfiguration driverConfiguration = new DriverConfiguration();

            Assert.IsNotNull(driverConfiguration);
            Assert.IsNotNull(driverConfiguration.Resilience);
            Assert.IsNotNull(driverConfiguration.Consensus);
            Assert.IsNotNull(driverConfiguration.Nodes);

            // Check default values
            Assert.IsFalse(driverConfiguration.Resilience.EnableCircuitBreaking);
            Assert.IsFalse(driverConfiguration.Resilience.EnableRetry);
            Assert.AreEqual(0, driverConfiguration.Nodes.Length);
            Assert.AreEqual(Consensus.ModelType.FirstWins, driverConfiguration.Consensus.Model);
            Assert.AreEqual(1, driverConfiguration.Consensus.InAgreement);
        }
        public SystemConfiguration(ISettingsReader settingsReader, [ImportMany] IEnumerable <IDocumentProcessorFactory> factories)
        {
            string fileName = settingsReader.GetSetting("printerConfigFile", string.Empty);

            Precondition.Assert(
                () => !string.IsNullOrEmpty(fileName) && File.Exists(fileName),
                "Invalid configuration provided - missing configuration file");

            using (Stream inputStream = File.OpenRead(fileName))
            {
                parser            = new PrinterConfigurationParser(factories);
                processorPipeline = parser.Parse(inputStream);
            }

            string printerDir     = parser.Variables.Get("printer-dir");
            string printerFileExt = parser.Variables.Get("printer-file-extension");
            string printerName    = parser.Variables.Get("printer-name");
            string driverName     = parser.Variables.Get("printer-driver");

            string port = Path.Combine(new DirectoryInfo(printerDir).FullName, Guid.NewGuid().ToString()) + printerFileExt;

            var driverConfiguration = new DriverConfiguration
            {
                ConfigFileName     = parser.Variables.Get("driver-config-file"),
                DataFileName       = parser.Variables.Get("driver-data-file"),
                DependentFileNames = parser.Variables.Get("driver-dependent-file").Split(","[0]),
                DriverFileName     = parser.Variables.Get("driver-path"),
                Environment        = parser.Variables.Get("driver-environment"),
                HelpFileName       = parser.Variables.Get("driver-help-file"),
                Name = parser.Variables.Get("driver-name")
            };

            printerConfiguration = new VirtualPrinterConfiguration
            {
                DefaultPort         = port,
                PrinterName         = printerName,
                DriverConfiguration = driverConfiguration
            };

            Logger.Info("Using the following configuration:");
            Logger.Info(string.Empty);
            Logger.InfoFormat("  Print Name:      {0}", printerName);
            Logger.InfoFormat("  Print Driver:    {0}", driverName);
            Logger.InfoFormat("  Print Directory: {0}", printerDir);
            Logger.InfoFormat("  File Extension:  {0}", printerFileExt);
            Logger.Info(string.Empty);
        }
Esempio n. 21
0
        public DriverConfigParam GetOrCreateParam(string Parameter, string DefaultValue = null)
        {
            foreach (DriverConfigParam DCP1 in DriverConfiguration)
            {
                if (DCP1.Parameter == Parameter)
                {
                    return(DCP1);
                }
            }

            DriverConfigParam DCP = new DriverConfigParam()
            {
                Parameter = Parameter, Value = DefaultValue
            };

            DriverConfiguration.Add(DCP);
            return(DCP);
        }
Esempio n. 22
0
        public DriverConfigParam GetOrCreateParam(string parameter, string defaultValue = null)
        {
            DriverConfigParam configParam = DriverConfiguration.Where(x => x.Parameter == parameter).FirstOrDefault();

            if (configParam != null)
            {
                return(configParam);
            }
            else
            {
                configParam = new DriverConfigParam()
                {
                    Parameter = parameter, Value = defaultValue
                };
                DriverConfiguration.Add(configParam);
                return(configParam);
            }
        }
Esempio n. 23
0
 public static void Seed(AppDbContext context, IConfiguration configuration)
 {
     TenantConfiguration.Seed(context, configuration);
     CardConfiguration.Seed(context);
     CardLayoutConfiguration.Seed(context);
     UserConfiguration.Seed(context, configuration);
     TaxConfiguration.Seed(context);
     DriverConfiguration.Seed(context, configuration);
     ProductConfiguration.Seed(context);
     WarehouseConfiguration.Seed(context);
     InventoryItemConfiguration.Seed(context);
     HtmlContentConfiguration.Seed(context);
     DigitalAssetConfiguration.Seed(context);
     EmailTemplateConfiguration.Seed(context);
     VideoConfiguration.Seed(context);
     ProfessionalServiceProviderConfiguration.Seed(context);
     //DashboardConfiguration.Seed(context);
 }
Esempio n. 24
0
        private void SetDriverDefualtParams(Type t)
        {
            MemberInfo[]            members = t.GetMembers();
            UserConfiguredAttribute token   = null;

            foreach (MemberInfo mi in members)
            {
                token = Attribute.GetCustomAttribute(mi, typeof(UserConfiguredAttribute), false) as UserConfiguredAttribute;

                if (token == null)
                {
                    continue;
                }
                DriverConfigParam configParam = GetDriverConfigParam(mi);


                DriverConfiguration.Add(configParam);
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Processes the driver configuration section of
        /// the app settings, adding each node as an
        /// HttpClient.
        /// <param name="services">The <see cref="IServiceCollection" /> which to configure.</param>
        /// </summary>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="services"/> is null.</exception>
        /// <exception cref="StartupException">Throw when the configuration json file driver configuration section does not include any nodes.</exception>
        /// <exception cref="StartupException">Throw when the appsettings.json a node in the nodes section does not specify a name.</exception>
        /// <exception cref="StartupException">Throw when the appsettings.json a node in the nodes section does not specify a Uri.</exception>
        public virtual void ConfigureHttpClients(IServiceCollection services)
        {
            services.IsNull("services");

            // Get the driver configuration
            DriverConfiguration driverConfiguration = new DriverConfiguration();

            Configuration.GetSection("DriverConfiguration").Bind(driverConfiguration);

            // Check nodes are specified
            if (driverConfiguration.Nodes == null || driverConfiguration.Nodes.Length == 0)
            {
                throw new StartupException("Configuration json file 'DriverConfiguration' section does not specify any nodes.");
            }

            // For each node, add an HttpClient to the services
            foreach (Node node in driverConfiguration.Nodes)
            {
                // Check that a
                if (node.Name == null || string.IsNullOrWhiteSpace(node.Name))
                {
                    throw new StartupException("Configuration json file 'DriverConfiguration.Nodes' section specifies a node without a name. Name is required.");
                }

                if (node.Uri == null)
                {
                    throw new StartupException("Configuration json file 'DriverConfiguration.Nodes' section specifies a node without a uri. Uri is required.");
                }

                // Add the Microsoft discovery service http client
                IHttpClientBuilder httpClientBuilder = services
                                                       .AddHttpClient(node.Name, client =>
                {
                    client.BaseAddress = node.Uri;
                    client.DefaultRequestHeaders.Add("Accept", "application/json");
                    client.Timeout = TimeSpan.FromMilliseconds(node.TimeoutInMilliseconds);
                });

                // Addd the retry policies to the client
                this.AddResiliencePolicy(httpClientBuilder, driverConfiguration.Resilience);
            }
        }
Esempio n. 26
0
        /// <summary>
        /// This function will add missing Driver config parameters to Driver configuration
        /// </summary>
        /// <param name="driverType"> Type of the driver</param>
        private void SetDriverMissingParams(Type driverType)
        {
            MemberInfo[]            members = driverType.GetMembers();
            UserConfiguredAttribute token   = null;

            foreach (MemberInfo mi in members)
            {
                token = Attribute.GetCustomAttribute(mi, typeof(UserConfiguredAttribute), false) as UserConfiguredAttribute;

                if (token == null)
                {
                    continue;
                }
                DriverConfigParam configParam = GetDriverConfigParam(mi);

                if (DriverConfiguration.Where(x => x.Parameter == configParam.Parameter).FirstOrDefault() == null)
                {
                    DriverConfiguration.Add(configParam);
                }
            }
        }
Esempio n. 27
0
        public void InitDriverConfigs()
        {
            if (DriverConfiguration == null)
            {
                DriverConfiguration = new ObservableList <DriverConfigParam>();
            }
            else
            {
                DriverConfiguration.Clear();
            }

            if (AgentType == eAgentType.Driver)
            {
                Type driverType = RepositoryItemHelper.RepositoryItemFactory.GetDriverType(this);
                SetDriverDefualtParams(driverType);
            }

            else if (AgentType == eAgentType.Service)
            {
                SetServiceConfiguration();
            }
        }
        protected void TakeScreenshot(WebDriverContext instance)
        {
            var cfg = DriverConfiguration.GetConfiguration();

            if (!cfg.TakeScreenshots)
            {
                return;
            }

            var testName = TestContext.CurrentContext.Test.Name;
            var invalids = Path.GetInvalidFileNameChars();

            testName = invalids.Aggregate(testName, (current, inv) => current.Replace(inv.ToString(), string.Empty));

            if (testName.Length > 200)
            {
                testName = testName.Substring(0, 200) + "...";
            }

            var path = Path.Combine(
                cfg.ScreenshotDir,
                testName);

            var di = new DirectoryInfo(path);

            if (!di.Exists)
            {
                Directory.CreateDirectory(path);
            }

            path = Path.Combine(
                di.FullName,
                StartTime.ToString(DateFormat) + ".png");

            instance.TakeScreenshot().SaveAsFile(
                path,
                ImageFormat.Png);
        }
        public void ConfigureHttpClients_ReturnsWithoutException()
        {
            try
            {
                ServiceCollection   serviceCollection   = new ServiceCollection();
                DriverConfiguration driverConfiguration = new DriverConfiguration();
                var mockConfiguration = new Mock <IConfiguration>();

                string currentDirectory = Directory.GetCurrentDirectory();
                string testsFolder      = currentDirectory.Substring(0, currentDirectory.IndexOf("bin"));

                IConfigurationRoot testConfig = new ConfigurationBuilder()
                                                .AddJsonFile($"{testsFolder}{Path.DirectorySeparatorChar}config.test.json", optional: false)
                                                .Build();

                Startup startup = new Startup(testConfig);
                startup.ConfigureHttpClients(serviceCollection);
            }
            catch (Exception exception)
            {
                throw new AssertFailedException($"Unexpected exception '{exception.Message}' executing 'Startup.ConfigureHttpClients(IServiceCollection)'. See inner exception for more details.", exception);
            }
        }
        public void ConfigureHttpClients_DriverConfigurationMissingNodeUri_ThrowsStartupException()
        {
            try
            {
                ServiceCollection   serviceCollection   = new ServiceCollection();
                DriverConfiguration driverConfiguration = new DriverConfiguration();
                var mockConfiguration = new Mock <IConfiguration>();

                string currentDirectory = Directory.GetCurrentDirectory();
                string testsFolder      = currentDirectory.Substring(0, currentDirectory.IndexOf("bin"));

                IConfigurationRoot testConfig = new ConfigurationBuilder()
                                                .AddJsonFile($"{testsFolder}{Path.DirectorySeparatorChar}config.nodesmissinguri.test.json", optional: false)
                                                .Build();

                Startup startup = new Startup(testConfig);
                startup.ConfigureHttpClients(serviceCollection);
                Assert.Fail("Expected a StartupException");
            }
            catch (StartupException startupException)
            {
                Assert.AreEqual("Configuration json file 'DriverConfiguration.Nodes' section specifies a node without a uri. Uri is required.", startupException.Message);
            }
        }