/// <summary> /// Initializes a new instance of the /// <see cref="OptionsCachingDriverFactoryProxy"/> class. /// </summary> /// <param name="proxiedFactory">The web driver factory to proxy.</param> /// <param name="options">The factory options object to pass to the proxied factory.</param> public OptionsCachingDriverFactoryProxy(ICreatesWebDriverFromOptions proxiedFactory, object options) { if (proxiedFactory == null) { throw new ArgumentNullException(nameof(proxiedFactory)); } this.options = options; this.proxiedFactory = proxiedFactory; }
public void CreateProvider_calls_method_from_proxied_type([Frozen] ICreatesWebDriverFromOptions proxied, OptionsCachingDriverFactoryProxy sut) { // Act sut.CreateWebDriver(); // Assert Mock.Get(proxied) .Verify(x => x.CreateWebDriver(It.IsAny <object>(), null, null, null), Times.Once); }
public void CreateProvider_passes_scenario_name_to_proxied_factory([Frozen] ICreatesWebDriverFromOptions proxied, OptionsCachingDriverFactoryProxy sut, string scenarioName) { // Act sut.CreateWebDriver(scenarioName: scenarioName); // Assert Mock.Get(proxied) .Verify(x => x.CreateWebDriver(It.IsAny <object>(), It.IsAny <IDictionary <string, object> >(), It.IsAny <IGetsBrowserFlags>(), scenarioName), Times.Once); }
public void CreateProvider_passes_flags_provider_to_proxied_factory([Frozen] ICreatesWebDriverFromOptions proxied, OptionsCachingDriverFactoryProxy sut, IGetsBrowserFlags flagsProvider) { // Act sut.CreateWebDriver(flagsProvider: flagsProvider); // Assert Mock.Get(proxied) .Verify(x => x.CreateWebDriver(It.IsAny <object>(), It.IsAny <IDictionary <string, object> >(), flagsProvider, It.IsAny <string>()), Times.Once); }
public void CreateProvider_passes_capabilities_to_proxied_factory([Frozen] ICreatesWebDriverFromOptions proxied, OptionsCachingDriverFactoryProxy sut, IDictionary <string, object> capabilities) { // Act sut.CreateWebDriver(requestedCapabilities: capabilities); // Assert Mock.Get(proxied) .Verify(x => x.CreateWebDriver(It.IsAny <object>(), capabilities, It.IsAny <IGetsBrowserFlags>(), It.IsAny <string>()), Times.Once); }
public void CreateProvider_passes_options_from_proxy([Frozen] ICreatesWebDriverFromOptions proxied, object options) { // Arrange var sut = new OptionsCachingDriverFactoryProxy(proxied, options); // Act var result = sut.CreateWebDriver(); // Assert Mock.Get(proxied) .Verify(x => x.CreateWebDriver(options, It.IsAny <IDictionary <string, object> >(), It.IsAny <IGetsBrowserFlags>(), It.IsAny <string>()), Times.Once); }
public void CreateProvider_returns_result_from_proxied_type([Frozen] ICreatesWebDriverFromOptions proxied, OptionsCachingDriverFactoryProxy sut, IWebDriver driver) { // Arrange Mock.Get(proxied) .Setup(x => x.CreateWebDriver(It.IsAny <object>(), null, null, null)) .Returns(driver); // Act var result = sut.CreateWebDriver(); // Assert Assert.That(result, Is.SameAs(driver)); }
public void GetProviderOptions_can_leave_a_nullable_integer_unset(ICreatesWebDriverFromOptions factory, FactoryOptionsFactory sut, [NoAutoProperties] SampleOptionsType expectedResult) { // Arrange Mock.Get(factory) .Setup(x => x.CreateEmptyOptions()) .Returns(expectedResult); var options = new Dictionary <string, string>(); // Act var result = (SampleOptionsType)sut.GetFactoryOptions(factory, options); // Assert Assert.That(result.ANullableIntegerProperty, Is.Null); }
public void GetProviderOptions_returns_created_instance_from_factory(ICreatesWebDriverFromOptions factory, FactoryOptionsFactory sut, SampleOptionsType expectedResult) { // Arrange Mock.Get(factory) .Setup(x => x.CreateEmptyOptions()) .Returns(expectedResult); var options = new Dictionary <string, string>(); // Act var result = sut.GetFactoryOptions(factory, options); // Assert Assert.That(result, Is.SameAs(expectedResult)); }
public void GetProviderOptions_can_set_a_nullable_integer(ICreatesWebDriverFromOptions factory, FactoryOptionsFactory sut, [NoAutoProperties] SampleOptionsType expectedResult, int expectedValue) { // Arrange Mock.Get(factory) .Setup(x => x.CreateEmptyOptions()) .Returns(expectedResult); var options = new Dictionary <string, string> { { nameof(SampleOptionsType.ANullableIntegerProperty), expectedValue.ToString() }, }; // Act var result = (SampleOptionsType)sut.GetFactoryOptions(factory, options); // Assert Assert.That(result.ANullableIntegerProperty, Is.EqualTo(expectedValue)); }
public void GetWebDriverProviderFactory_returns_proxy_when_factory_supports_options(ICreatesWebDriverFactory factoryCreator, ICreatesFactoryOptions optionsCreator, IDescribesWebDriverFactory config, ICreatesWebDriverFromOptions factory, object options, string typeName, Dictionary <string, string> optionsDictionary) { // Arrange var sut = new WebDriverFactorySource(factoryCreator, optionsCreator); Mock.Get(config) .Setup(x => x.GetFactoryAssemblyQualifiedTypeName()) .Returns(typeName); Mock.Get(config) .Setup(x => x.GetOptionKeyValuePairs()) .Returns(optionsDictionary); Mock.Get(factoryCreator) .Setup(x => x.GetFactory(It.IsAny <string>())) .Returns(factory); Mock.Get(optionsCreator) .Setup(x => x.GetFactoryOptions(factory, It.IsAny <IDictionary <string, string> >())) .Returns(options); // Act var result = sut.CreateFactory(config); // Assert Assert.That(result, Is.InstanceOf <OptionsCachingDriverFactoryProxy>()); var proxy = (OptionsCachingDriverFactoryProxy)result; Assert.That(proxy.ProxiedFactory, Is.SameAs(factory)); }