예제 #1
0
        public void TestReadWriteConfiguration()
        {
            var section = new ConfigurationSectionHandler
                              {
                                 Application = new ApplicationConfigurationElement
                                      {
                                          StartUrl = "http://myapp.com"
                                      },
                                 BrowserFactory = new BrowserFactoryConfigurationElement
                                                      {
                                                          BrowserType = "Chrome",
                                                          Provider = "MyProvider, MyProvider.Class",
                                                          EnsureCleanSession = true,
                                                          ElementLocateTimeout = TimeSpan.FromSeconds(10),
                                                          PageLoadTimeout = TimeSpan.FromSeconds(15),
                                                      }
                              };

            Assert.IsNotNull(section.Application);
            Assert.AreEqual("http://myapp.com", section.Application.StartUrl);

            Assert.IsNotNull(section.BrowserFactory);
            Assert.AreEqual("MyProvider, MyProvider.Class", section.BrowserFactory.Provider);
            Assert.AreEqual("Chrome", section.BrowserFactory.BrowserType);
            Assert.AreEqual(TimeSpan.FromSeconds(10), section.BrowserFactory.ElementLocateTimeout);
            Assert.AreEqual(TimeSpan.FromSeconds(15), section.BrowserFactory.PageLoadTimeout);
            Assert.AreEqual(true, section.BrowserFactory.EnsureCleanSession);
            Assert.IsNotNull(section.BrowserFactory.Settings);
        }
        /// <summary>
        /// Creates the configuration node from XML.
        /// </summary>
        /// <param name="xmlContent">Content of the XML.</param>
        /// <returns>The created configuration section.</returns>
        public static ConfigurationSectionHandler CreateFromXml(string xmlContent)
        {
            var section = new ConfigurationSectionHandler();
            section.Init();

            // ReSharper disable once AssignNullToNotNullAttribute
            section.Reset(null);
            
            using (var reader = new XmlTextReader(new StringReader(xmlContent.Trim())))
            {
                section.DeserializeSection(reader);
            }
            section.ResetModified();
            return section;
        }
예제 #3
0
        /// <summary>
        /// Creates the configuration node from XML.
        /// </summary>
        /// <param name="xmlContent">Content of the XML.</param>
        /// <returns>The created configuration section.</returns>
        public static ConfigurationSectionHandler CreateFromXml(string xmlContent)
        {
            var section = new ConfigurationSectionHandler();

            section.Init();

            // ReSharper disable once AssignNullToNotNullAttribute
            section.Reset(null);

            using (var reader = new XmlTextReader(new StringReader(xmlContent.Trim())))
            {
                section.DeserializeSection(reader);
            }
            section.ResetModified();
            return(section);
        }
예제 #4
0
        public void TestTearDownAfterScenarioWhenReuseBrowserIsFalse()
        {
            // arrange
            var config = new ConfigurationSectionHandler
            {
                BrowserFactory =
                    new BrowserFactoryConfigurationElement
                    {
                        ReuseBrowser = false
                    }
            };

            var browser = new Mock<IBrowser>(MockBehavior.Strict);
            browser.Setup(b => b.Close(true));
            WebDriverSupport.Browser = browser.Object;
            WebDriverSupport.ConfigurationMethod = new Lazy<ConfigurationSectionHandler>(() => config);

            // act
            WebDriverSupport.TearDownAfterScenario();

            // assert
            browser.VerifyAll();
        }