public void FindElementDisjunct()
        {
            var driver = new Mock <IAllDriver>();

            var elem1 = new Mock <IAllElement>();
            var elem2 = new Mock <IAllElement>();
            var elem3 = new Mock <IAllElement>();
            var elem4 = new Mock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1.Object, elem2.Object
            }.AsReadOnly();
            var elems34 = new List <IWebElement> {
                elem3.Object, elem4.Object
            }.AsReadOnly();

            driver.Setup(_ => _.FindElements(by.Mechanism, by.Criteria)).Returns(elems12);
            driver.Setup(_ => _.FindElements(by2.Mechanism, by2.Criteria)).Returns(elems34);

            var byAll = new ByAll(by, by2);

            Assert.Throws <NoSuchElementException>(() => byAll.FindElement(driver.Object));

            var result = byAll.FindElements(driver.Object);

            Assert.That(result.Count, Is.EqualTo(0));
            driver.Verify(_ => _.FindElements(by.Mechanism, by.Criteria), Times.AtLeastOnce);
            driver.Verify(_ => _.FindElements(by2.Mechanism, by2.Criteria), Times.AtLeastOnce);
        }
        public void FindElementTwoBy()
        {
            var driver = new Mock <IAllDriver>();

            var elem1 = new Mock <IAllElement>();
            var elem2 = new Mock <IAllElement>();
            var elem3 = new Mock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1.Object, elem2.Object
            }.AsReadOnly();
            var elems23 = new List <IWebElement> {
                elem2.Object, elem3.Object
            }.AsReadOnly();

            driver.Setup(_ => _.FindElements(by.Mechanism, by.Criteria)).Returns(elems12);
            driver.Setup(_ => _.FindElements(by2.Mechanism, by2.Criteria)).Returns(elems23);

            var byAll = new ByAll(by, by2);

            // findElement
            Assert.That(byAll.FindElement(driver.Object), Is.EqualTo(elem2.Object));

            //findElements
            var result = byAll.FindElements(driver.Object);

            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result[0], Is.EqualTo(elem2.Object));

            driver.Verify(_ => _.FindElements(by.Mechanism, by.Criteria), Times.AtLeastOnce);
            driver.Verify(_ => _.FindElements(by2.Mechanism, by2.Criteria), Times.AtLeastOnce);
        }
        public void FindElementTwoBy()
        {
            var driver = new Mock <IAllDriver>();

            var elem1 = new Mock <IAllElement>();
            var elem2 = new Mock <IAllElement>();
            var elem3 = new Mock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1.Object, elem2.Object
            }.AsReadOnly();
            var elems23 = new List <IWebElement> {
                elem2.Object, elem3.Object
            }.AsReadOnly();

            driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "cheese"))).Returns(elems12);
            driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "photo"))).Returns(elems23);

            var by = new ByAll(By.Name("cheese"), By.Name("photo"));

            // findElement
            Assert.That(by.FindElement(driver.Object), Is.EqualTo(elem2.Object));

            //findElements
            var result = by.FindElements(driver.Object);

            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result[0], Is.EqualTo(elem2.Object));

            driver.Verify(_ => _.FindElementsByName("cheese"), Times.AtLeastOnce);
            driver.Verify(_ => _.FindElementsByName("photo"), Times.AtLeastOnce);
        }
        public void FindElementDisjunct()
        {
            var driver = new Mock <IAllDriver>();

            var elem1 = new Mock <IAllElement>();
            var elem2 = new Mock <IAllElement>();
            var elem3 = new Mock <IAllElement>();
            var elem4 = new Mock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1.Object, elem2.Object
            }.AsReadOnly();
            var elems34 = new List <IWebElement> {
                elem3.Object, elem4.Object
            }.AsReadOnly();

            driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "cheese"))).Returns(elems12);
            driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "photo"))).Returns(elems34);

            var by = new ByAll(By.Name("cheese"), By.Name("photo"));

            Assert.Throws <NoSuchElementException>(() => by.FindElement(driver.Object));

            var result = by.FindElements(driver.Object);

            Assert.That(result.Count, Is.EqualTo(0));
            driver.Verify(_ => _.FindElementsByName("cheese"), Times.AtLeastOnce);
            driver.Verify(_ => _.FindElementsByName("photo"), Times.AtLeastOnce);
        }
        public void FindElementZeroBy()
        {
            var driver = new Mock <IAllDriver>();

            var byAll = new ByAll();

            Assert.Throws <NoSuchElementException>(() => byAll.FindElement(driver.Object));
            Assert.That(byAll.FindElements(driver.Object), Is.EqualTo(new List <IWebElement>().AsReadOnly()));
        }
        public void FindElementOneByEmpty()
        {
            var driver = new Mock <IAllDriver>();
            var empty  = new List <IWebElement>().AsReadOnly();

            driver.Setup(_ => _.FindElements(by.Mechanism, by.Criteria)).Returns(empty);

            var byAll = new ByAll(by);

            // one element
            Assert.Throws <NoSuchElementException>(() => byAll.FindElement(driver.Object));
            Assert.That(byAll.FindElements(driver.Object), Is.EqualTo(empty));

            driver.Verify(_ => _.FindElements(by.Mechanism, by.Criteria), Times.AtLeastOnce);
        }
        public void FindElementOneByEmpty()
        {
            var driver = new Mock <IAllDriver>();
            var empty  = new List <IWebElement>().AsReadOnly();

            driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "cheese"))).Returns(empty);

            var by = new ByAll(By.Name("cheese"));

            // one element
            Assert.Throws <NoSuchElementException>(() => by.FindElement(driver.Object));
            Assert.That(by.FindElements(driver.Object), Is.EqualTo(empty));

            driver.Verify(_ => _.FindElementsByName("cheese"), Times.AtLeastOnce);
        }
        public void FindElementOneBy()
        {
            var driver = new Mock <IAllDriver>();
            var elem1 = new Mock <IAllElement>();
            var elem2 = new Mock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1.Object, elem2.Object
            }.AsReadOnly();

            driver.Setup(_ => _.FindElements(by.Mechanism, by.Criteria)).Returns(elems12);
            var byAll = new ByAll(by);

            // findElement
            Assert.That(elem1.Object, Is.EqualTo(byAll.FindElement(driver.Object)));
            //findElements
            Assert.That(byAll.FindElements(driver.Object), Is.EqualTo(elems12));

            driver.Verify(_ => _.FindElements(by.Mechanism, by.Criteria), Times.AtLeastOnce);
        }
        public void FindElementOneBy()
        {
            var driver = new Mock <IAllDriver>();
            var elem1 = new Mock <IAllElement>();
            var elem2 = new Mock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1.Object, elem2.Object
            }.AsReadOnly();

            driver.Setup(_ => _.FindElementsByName(It.Is <string>(x => x == "cheese"))).Returns(elems12);
            var by = new ByAll(By.Name("cheese"));

            // findElement
            Assert.AreEqual(by.FindElement(driver.Object), elem1.Object);
            //findElements
            Assert.That(by.FindElements(driver.Object), Is.EqualTo(elems12));

            driver.Verify(_ => _.FindElementsByName("cheese"), Times.AtLeastOnce);
        }