public void FindElements_SingleBy_ShouldCallFindElementsOfAllTheBy() { var byMock = new Mock <OpenQA.Selenium.By>(); var byEach = new ByEach(byMock.Object); byEach.FindElements(_webElementMock.Object); byMock.Verify(by => by.FindElements(_webElementMock.Object), Times.Once); }
public void FindElements_ShouldReturnTheIntersectionOfAllBysFindElementsResults() { var resultWebElementMock1 = new Mock <IWebElement>(); var resultWebElementMock2 = new Mock <IWebElement>(); var resultWebElementMock3 = new Mock <IWebElement>(); var result1List = new List <IWebElement>() { resultWebElementMock1.Object, resultWebElementMock2.Object }; var result2List = new List <IWebElement>() { resultWebElementMock3.Object, resultWebElementMock2.Object, resultWebElementMock1.Object }; var result3List = new List <IWebElement>() { resultWebElementMock2.Object }; var by1Mock = new Mock <OpenQA.Selenium.By>(); by1Mock.Setup(by => by.FindElements(It.IsAny <ISearchContext>())).Returns(() => new ReadOnlyCollection <IWebElement>(result1List)); var by2Mock = new Mock <OpenQA.Selenium.By>(); by2Mock.Setup(by => by.FindElements(It.IsAny <ISearchContext>())).Returns(() => new ReadOnlyCollection <IWebElement>(result2List)); var by3Mock = new Mock <OpenQA.Selenium.By>(); by3Mock.Setup(by => by.FindElements(It.IsAny <ISearchContext>())).Returns(() => new ReadOnlyCollection <IWebElement>(result3List)); var byEach = new ByEach(by1Mock.Object, by2Mock.Object, by3Mock.Object); var resultElements = byEach.FindElements(_webElementMock.Object); Assert.AreEqual(1, resultElements.Count); Assert.AreSame(resultWebElementMock2.Object, resultElements[0]); }