Exemplo n.º 1
0
        public void TestTryGetElementWhenElementGetIsSuccessful()
        {
            var resultPropertyData = new Mock <IPropertyData>().Object;

            var page = new Mock <IPage>(MockBehavior.Strict);

            page.Setup(p => p.TryGetElement("MyElement", out resultPropertyData)).Returns(true);

            var locatorAction = new Mock <ILocatorAction>(MockBehavior.Strict);

            locatorAction.Setup(p => p.OnLocate("MyElement"));
            locatorAction.Setup(p => p.OnLocateComplete("MyElement", resultPropertyData));

            var locator = new ElementLocator(page.Object, new[] { locatorAction.Object });

            IPropertyData propertyData;
            var           result = locator.TryGetElement("MyElement", out propertyData);

            Assert.IsTrue(result);
            Assert.IsNotNull(propertyData);
            Assert.AreSame(resultPropertyData, propertyData);

            page.VerifyAll();
            locatorAction.VerifyAll();
        }
Exemplo n.º 2
0
        public void TestTryGetElementWhenElementGetFails()
        {
            IPropertyData resultPropertyData;

            var page = new Mock <IPage>(MockBehavior.Strict);

            page.Setup(p => p.TryGetElement("MyElement", out resultPropertyData)).Returns(false);

            var locatorAction = new Mock <ILocatorAction>(MockBehavior.Strict);

            locatorAction.Setup(p => p.OnLocate("MyElement"));
            locatorAction.Setup(p => p.OnLocateComplete("MyElement", null));

            var locator = new ElementLocator(page.Object, new[] { locatorAction.Object });

            IPropertyData propertyData;
            var           result = locator.TryGetElement("MyElement", out propertyData);

            Assert.IsFalse(result);
            Assert.IsNull(propertyData);

            page.VerifyAll();
            locatorAction.VerifyAll();
        }