Esempio n. 1
0
        public void TestTryGetPropertyWhenPropertyGetIsSuccessful()
        {
            var resultPropertyData = new Mock <IPropertyData>().Object;

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

            page.Setup(p => p.TryGetProperty("MyProperty", out resultPropertyData)).Returns(true);

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

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

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

            IPropertyData propertyData;
            var           result = locator.TryGetProperty("MyProperty", out propertyData);

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

            page.VerifyAll();
            locatorAction.VerifyAll();
        }
Esempio n. 2
0
        public void TestTryGetPropertyWhenPropertyGetFails()
        {
            IPropertyData resultPropertyData;

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

            page.Setup(p => p.TryGetProperty("MyProperty", out resultPropertyData)).Returns(false);

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

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

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

            IPropertyData propertyData;
            var           result = locator.TryGetProperty("MyProperty", out propertyData);

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

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