public void CreateReturnsExactMatchingTypeTest()
        {
            var page = new HtmlPageStub("<input type='text' />");

            var target = new DefaultHtmlElementFactory();

            var actual = target.Create<HtmlInput>(page, ((IHtmlPage)page).Node);

            actual.Should().NotBeNull();
        }
        public void CreateReturnsExactMatchingTypeTest()
        {
            var page = new HtmlPageStub("<input type='text' />");

            var target = new DefaultHtmlElementFactory();

            var actual = target.Create <HtmlInput>(page, ((IHtmlPage)page).Node);

            actual.Should().NotBeNull();
        }
        public void CreateThrowsExceptionWhenRequestedTypeIsNotValidTest()
        {
            var page = Substitute.For<IHtmlPage>();
            var node = Substitute.For<IXPathNavigable>();
            var navigator = Substitute.For<XPathNavigator>();

            node.CreateNavigator().Returns(navigator);
            navigator.Name.Returns("input");
            navigator.GetAttribute("type", string.Empty).Returns("text");

            var target = new DefaultHtmlElementFactory();

            Action action = () => target.Create<HtmlButton>(page, node);

            action.ShouldThrow<InvalidOperationException>();
        }
        public void CreateThrowsExceptionWhenRequestedTypeIsNotValidTest()
        {
            var page      = Substitute.For <IHtmlPage>();
            var node      = Substitute.For <IXPathNavigable>();
            var navigator = Substitute.For <XPathNavigator>();

            node.CreateNavigator().Returns(navigator);
            navigator.Name.Returns("input");
            navigator.GetAttribute("type", string.Empty).Returns("text");

            var target = new DefaultHtmlElementFactory();

            Action action = () => target.Create <HtmlButton>(page, node);

            action.ShouldThrow <InvalidOperationException>();
        }