public void TestExecuteWhenPropertyValidationReturnsErrorsReturnsFailureResult() { var propData = new Mock <IPropertyData>(MockBehavior.Strict); propData.SetupGet(p => p.IsList).Returns(true); propData.SetupGet(p => p.Name).Returns("MyProperty"); propData.Setup(p => p.ValidateListRowCount(NumericComparisonType.Equals, 1)) .Returns(new Tuple <bool, int>(false, 2)); var locator = new Mock <IElementLocator>(MockBehavior.Strict); locator.Setup(p => p.GetProperty("myproperty")).Returns(propData.Object); var rowCountAction = new ValidateListRowCountAction { ElementLocator = locator.Object }; var context = new ValidateListRowCountAction.ValidateListRowCountContext("myproperty", NumericComparisonType.Equals, 1); var result = rowCountAction.Execute(context); Assert.AreEqual(false, result.Success); Assert.AreEqual("List count validation of field 'MyProperty' failed. Expected Items: 1, Actual Items: 2", result.Exception.Message); locator.VerifyAll(); propData.VerifyAll(); }
public void TestExecuteWhenPropertyIsNotAListReturnsFailureResult() { var propData = new Mock <IPropertyData>(MockBehavior.Strict); propData.SetupGet(p => p.IsList).Returns(false); propData.SetupGet(p => p.Name).Returns("MyProperty"); var locator = new Mock <IElementLocator>(MockBehavior.Strict); locator.Setup(p => p.GetProperty("myproperty")).Returns(propData.Object); var rowCountAction = new ValidateListRowCountAction { ElementLocator = locator.Object }; var context = new ValidateListRowCountAction.ValidateListRowCountContext("myproperty", NumericComparisonType.Equals, 1); var result = rowCountAction.Execute(context); Assert.AreEqual(false, result.Success); Assert.AreEqual("Property 'MyProperty' was found but is not a list element.", result.Exception.Message); locator.VerifyAll(); propData.VerifyAll(); }
public void TestExecuteWhenPropertyValidationReturnsSuccessReturnsASuccess() { var propData = new Mock <IPropertyData>(MockBehavior.Strict); propData.SetupGet(p => p.IsList).Returns(true); propData.Setup(p => p.ValidateListRowCount(NumericComparisonType.Equals, 1)) .Returns(new Tuple <bool, int>(true, 1)); var locator = new Mock <IElementLocator>(MockBehavior.Strict); locator.Setup(p => p.GetProperty("myproperty")).Returns(propData.Object); var rowCountAction = new ValidateListRowCountAction { ElementLocator = locator.Object }; var context = new ValidateListRowCountAction.ValidateListRowCountContext("myproperty", NumericComparisonType.Equals, 1); var result = rowCountAction.Execute(context); Assert.AreEqual(true, result.Success); locator.VerifyAll(); propData.VerifyAll(); }
public void TestExecuteWhenFieldDoesNotExistThrowsAnException() { var locator = new Mock<IElementLocator>(MockBehavior.Strict); locator.Setup(p => p.GetProperty("doesnotexist")).Throws(new ElementExecuteException("Cannot find item")); var rowCountAction = new ValidateListRowCountAction { ElementLocator = locator.Object }; var context = new ValidateListRowCountAction.ValidateListRowCountContext("doesnotexist", NumericComparisonType.Equals, 1); ExceptionHelper.SetupForException<ElementExecuteException>( () => rowCountAction.Execute(context), e => locator.VerifyAll()); }
public void TestExecuteWhenFieldDoesNotExistThrowsAnException() { var locator = new Mock <IElementLocator>(MockBehavior.Strict); locator.Setup(p => p.GetProperty("doesnotexist")).Throws(new ElementExecuteException("Cannot find item")); var rowCountAction = new ValidateListRowCountAction { ElementLocator = locator.Object }; var context = new ValidateListRowCountAction.ValidateListRowCountContext("doesnotexist", NumericComparisonType.Equals, 1); ExceptionHelper.SetupForException <ElementExecuteException>( () => rowCountAction.Execute(context), e => locator.VerifyAll()); }
public void TestExecuteWhenPropertyIsNotAListReturnsFailureResult() { var propData = new Mock<IPropertyData>(MockBehavior.Strict); propData.SetupGet(p => p.IsList).Returns(false); propData.SetupGet(p => p.Name).Returns("MyProperty"); var locator = new Mock<IElementLocator>(MockBehavior.Strict); locator.Setup(p => p.GetProperty("myproperty")).Returns(propData.Object); var rowCountAction = new ValidateListRowCountAction { ElementLocator = locator.Object }; var context = new ValidateListRowCountAction.ValidateListRowCountContext("myproperty", NumericComparisonType.Equals, 1); var result = rowCountAction.Execute(context); Assert.AreEqual(false, result.Success); Assert.AreEqual("Property 'MyProperty' was found but is not a list element.", result.Exception.Message); locator.VerifyAll(); propData.VerifyAll(); }
public void TestExecuteWhenPropertyValidationReturnsErrorsReturnsFailureResult() { var propData = new Mock<IPropertyData>(MockBehavior.Strict); propData.SetupGet(p => p.IsList).Returns(true); propData.SetupGet(p => p.Name).Returns("MyProperty"); propData.Setup(p => p.ValidateListRowCount(NumericComparisonType.Equals, 1)) .Returns(new Tuple<bool, int>(false, 2)); var locator = new Mock<IElementLocator>(MockBehavior.Strict); locator.Setup(p => p.GetProperty("myproperty")).Returns(propData.Object); var rowCountAction = new ValidateListRowCountAction { ElementLocator = locator.Object }; var context = new ValidateListRowCountAction.ValidateListRowCountContext("myproperty", NumericComparisonType.Equals, 1); var result = rowCountAction.Execute(context); Assert.AreEqual(false, result.Success); Assert.AreEqual("List count validation of field 'MyProperty' failed. Expected Items: 1, Actual Items: 2", result.Exception.Message); locator.VerifyAll(); propData.VerifyAll(); }
public void TestExecuteWhenPropertyValidationReturnsSuccessReturnsASuccess() { var propData = new Mock<IPropertyData>(MockBehavior.Strict); propData.SetupGet(p => p.IsList).Returns(true); propData.Setup(p => p.ValidateListRowCount(NumericComparisonType.Equals, 1)) .Returns(new Tuple<bool, int>(true, 1)); var locator = new Mock<IElementLocator>(MockBehavior.Strict); locator.Setup(p => p.GetProperty("myproperty")).Returns(propData.Object); var rowCountAction = new ValidateListRowCountAction { ElementLocator = locator.Object }; var context = new ValidateListRowCountAction.ValidateListRowCountContext("myproperty", NumericComparisonType.Equals, 1); var result = rowCountAction.Execute(context); Assert.AreEqual(true, result.Success); locator.VerifyAll(); propData.VerifyAll(); }