public void Decorate_IWebElementEnumerable_Unsupported(
     Type type,
     IEnumerable <By> bys,
     IElementLocator elementLocator,
     ProxyPageObjectMemberDecorator sut)
 {
     new Action(() => sut.Decorate(type, bys, elementLocator))
     .Should()
     .Throw <DecorationException>()
     .WithMessage($"Unable to decorate {type.Name}, it is unsupported");
 }
        public void Decorate_IWebElement(
            IEnumerable <By> bys,
            IElementLocator elementLocator,
            [Frozen] Mock <IWebDriver> webDriverMock,
            [Frozen] WrapsElement wrapsElement,
            [Frozen] Mock <IElementActivator> elementActivatorMock,
            ProxyPageObjectMemberDecorator sut)
        {
            var result = sut.Decorate(typeof(IWebElement), bys, elementLocator);

            result.GetType().Name.Should().Contain("Proxy");
        }
        public void Decorate_IWrapsElementIEnumerableImplementation(
            Type type,
            IEnumerable <By> bys,
            IElementLocator elementLocator,
            [Frozen] WrapsElement wrapsElement,
            [Frozen] Mock <IElementActivator> elementActivatorMock,
            ProxyPageObjectMemberDecorator sut)
        {
            elementActivatorMock
            .Setup(x => x.Create(type, It.IsAny <object[]>()))
            .Returns(wrapsElement);

            new Action(() => sut.Decorate(type, bys, elementLocator)).Should().NotThrow();
        }
        public void Decorate_IWebElementEnumerable(
            Type type,
            IEnumerable <By> bys,
            IElementLocator elementLocator,
            [Frozen] Mock <IWebDriver> webDriverMock,
            [Frozen] WrapsElement wrapsElement,
            [Frozen] Mock <IElementActivator> elementActivatorMock,
            ProxyPageObjectMemberDecorator sut)
        {
            var result = (IEnumerable <IWebElement>)sut.Decorate(type, bys, elementLocator);

            foreach (var member in result)
            {
                member.Should().GetType().Name.Should().Contain("Proxy");
            }
        }
        public void Decorate_IWrapsElementIEnumerableImplementation_Unsupported(
            Type type,
            IEnumerable <By> bys,
            IElementLocator elementLocator,
            [Frozen] WrapsElement wrapsElement,
            [Frozen] Mock <IElementActivator> elementActivatorMock,
            ProxyPageObjectMemberDecorator sut)
        {
            elementActivatorMock
            .Setup(x => x.Create(type, It.IsAny <object[]>()))
            .Returns(wrapsElement);

            new Action(() => sut.Decorate(type, bys, elementLocator)).Should()
            .Throw <DecorationException>()
            .WithMessage($"Unable to decorate {type.Name}, it is unsupported");
        }
        public void Decorate_IWrapsElementImplementation(
            IEnumerable <By> bys,
            IElementLocator elementLocator,
            [Frozen] Mock <IWebDriver> webDriverMock,
            [Frozen] WrapsElement wrapsElement,
            [Frozen] Mock <IElementActivator> elementActivatorMock,
            ProxyPageObjectMemberDecorator sut)
        {
            elementActivatorMock
            .Setup(x => x.Create(typeof(WrapsElement), It.IsAny <object[]>()))
            .Callback(new Action <Type, object[]>((typeToActivate, args) =>
            {
                args[0].GetType().Name.Should().Contain("Proxy");
            }))
            .Returns(wrapsElement);

            var result = sut.Decorate(typeof(WrapsElement), bys, elementLocator);

            result.Should().BeOfType <WrapsElement>();
            elementActivatorMock
            .Verify(x => x.Create(typeof(WrapsElement), It.IsAny <object[]>()), Times.Once());
        }