public void Matches_AllValidatePredicate_False() { var rs = new ResultSet(); rs.Load(new[] { new object[] { "a", -1 }, new object[] { "b", -2 }, new object[] { "c", -3 } }); var predicate = Mock.Of <IPredicateInfo> ( p => p.ColumnType == ColumnType.Numeric && p.ComparerType == ComparerType.LessThan && p.Operand == "#1" && p.Reference == (object)0 ); var factory = new PredicateFilterFactory(); var filter = factory.Instantiate ( new List <IColumnAlias>() , new List <IColumnExpression>() , predicate ); var singleRowCtr = new SingleRowConstraint(filter); Assert.That(singleRowCtr.Matches(rs), Is.False); }
public void Matches_AllValidatePredicate_False() { var rs = new ResultSet(); rs.Load(new[] { new object[] { "a", -1 }, new object[] { "b", -2 }, new object[] { "c", -3 } }); var predicate = new Mock <ReferencePredicateArgs>(); predicate.SetupGet(p => p.ColumnType).Returns(ColumnType.Numeric); predicate.SetupGet(p => p.ComparerType).Returns(ComparerType.LessThan); predicate.SetupGet(p => p.Reference).Returns(new LiteralScalarResolver <decimal>(0)); var predication = new Mock <PredicationArgs>(); predication.SetupGet(p => p.Identifier).Returns(new ColumnOrdinalIdentifier(1)); predication.SetupGet(p => p.Predicate).Returns(predicate.Object); var factory = new ResultSetFilterFactory(null); var filter = factory.Instantiate ( predication.Object , Context.None ); var singleRowCtr = new SingleRowConstraint(filter); Assert.That(singleRowCtr.Matches(rs), Is.False); }
public void Matches_AllValidatePredicate_False() { var rs = new ResultSet(); rs.Load(new[] { new object[] { "a", -1 }, new object[] { "b", -2 }, new object[] { "c", -3 } }); var predicate = new Mock <IPredicateInfo>(); predicate.SetupGet(p => p.ColumnType).Returns(ColumnType.Numeric); predicate.SetupGet(p => p.ComparerType).Returns(ComparerType.LessThan); predicate.SetupGet(p => p.Operand).Returns("#1"); predicate.As <IReferencePredicateInfo>().SetupGet(p => p.Reference).Returns((object)0); var factory = new PredicateFilterFactory(); var filter = factory.Instantiate ( new List <IColumnAlias>() , new List <IColumnExpression>() , predicate.Object ); var singleRowCtr = new SingleRowConstraint(filter); Assert.That(singleRowCtr.Matches(rs), Is.False); }
public void Matches_ResultSetService_CallToExecuteOnce() { var resultSet = new ResultSet(); resultSet.Load("a;b;1"); var serviceMock = new Mock <IResultSetService>(); serviceMock.Setup(s => s.Execute()) .Returns(resultSet); var service = serviceMock.Object; var alias = Mock.Of <IColumnAlias>(v => v.Column == 2 && v.Name == "Value"); var predicate = new Mock <ReferencePredicateArgs>(); predicate.SetupGet(p => p.ColumnType).Returns(ColumnType.Numeric); predicate.SetupGet(p => p.ComparerType).Returns(ComparerType.Equal); predicate.SetupGet(p => p.Reference).Returns(new LiteralScalarResolver <decimal>(1)); var predication = new Mock <PredicationArgs>(); predication.SetupGet(p => p.Identifier).Returns(new ColumnNameIdentifier("Value")); predication.SetupGet(p => p.Predicate).Returns(predicate.Object); var factory = new ResultSetFilterFactory(null); var filter = factory.Instantiate ( predication.Object , new Context(null, new List <IColumnAlias>() { alias }, Array.Empty <IColumnExpression>()) ); var singleRowCtr = new SingleRowConstraint(filter); //Method under test singleRowCtr.Matches(service); //Test conclusion serviceMock.Verify(s => s.Execute(), Times.Once()); }
public void Matches_ResultSetService_CallToExecuteOnce() { var resultSet = new ResultSet(); resultSet.Load("a;b;1"); var serviceMock = new Mock <IResultSetService>(); serviceMock.Setup(s => s.Execute()) .Returns(resultSet); var service = serviceMock.Object; var alias = Mock.Of <IColumnAlias>(v => v.Column == 2 && v.Name == "Value"); var predicate = Mock.Of <IPredicateInfo> ( p => p.ColumnType == ColumnType.Numeric && p.ComparerType == ComparerType.Equal && p.Operand == "Value" && p.Reference == (object)1 ); var factory = new PredicateFilterFactory(); var filter = factory.Instantiate ( new List <IColumnAlias>() { alias } , new List <IColumnExpression>() { } , predicate ); var singleRowCtr = new SingleRowConstraint(filter); //Method under test singleRowCtr.Matches(service); //Test conclusion serviceMock.Verify(s => s.Execute(), Times.Once()); }