public void Execute_TrueFalseTrue_GoUntilTheEnd() { var predicationMock1 = new Mock <IPredication>(); predicationMock1.Setup(x => x.Execute(It.IsAny <Context>())).Returns(true); var predicationMock2 = new Mock <IPredication>(); predicationMock2.Setup(x => x.Execute(It.IsAny <Context>())).Returns(false); var predicationMock3 = new Mock <IPredication>(); predicationMock3.Setup(x => x.Execute(It.IsAny <Context>())).Returns(false); var factory = new PredicationFactory(); var predication = factory.Instantiate(new[] { predicationMock1.Object, predicationMock2.Object, predicationMock3.Object }, CombinationOperator.XOr); var context = Context.None; var dt = new DataTable(); var row = dt.NewRow(); predication.Execute(context); predicationMock1.Verify(x => x.Execute(context), Times.Once); predicationMock2.Verify(x => x.Execute(context), Times.Once); predicationMock3.Verify(x => x.Execute(context), Times.Once); }
public void Execute_FalseTrue_True() { var leftPredication = Mock.Of <IPredication>(x => x.Execute(It.IsAny <Context>()) == false); var RightPredication = Mock.Of <IPredication>(x => x.Execute(It.IsAny <Context>()) == true); var factory = new PredicationFactory(); var predication = factory.Instantiate(new[] { leftPredication, RightPredication }, CombinationOperator.XOr); var context = Context.None; var dt = new DataTable(); var row = dt.NewRow(); Assert.That(predication.Execute(context), Is.True); }
public void Execute_FalseTrue_StopOnFirst() { var leftPredicationMock = new Mock <IPredication>(); leftPredicationMock.Setup(x => x.Execute(It.IsAny <Context>())).Returns(false); var rightPredicationMock = new Mock <IPredication>(); rightPredicationMock.Setup(x => x.Execute(It.IsAny <Context>())).Returns(true); var factory = new PredicationFactory(); var predication = factory.Instantiate(new[] { leftPredicationMock.Object, rightPredicationMock.Object }, CombinationOperator.And); var context = Context.None; var dt = new DataTable(); var row = dt.NewRow(); context.Switch(row); predication.Execute(context); leftPredicationMock.Verify(x => x.Execute(context), Times.Once); rightPredicationMock.Verify(x => x.Execute(It.IsAny <Context>()), Times.Never); }