public void LinqWhere_Boolean() { TestCluster.PrimeFluent( b => b.WhenQuery( "SELECT \"BooleanType\", \"DateTimeOffsetType\", \"DateTimeType\", \"DecimalType\", " + "\"DictionaryStringLongType\", \"DictionaryStringStringType\", \"DoubleType\", \"FloatType\", " + "\"GuidType\", \"Int64Type\", \"IntType\", \"ListOfGuidsType\", \"ListOfStringsType\", " + "\"NullableIntType\", \"StringType\" " + $"FROM \"{ManyDataTypesEntity.TableName}\" " + $"WHERE \"BooleanType\" = ? " + "ALLOW FILTERING", p => p.WithParams(true)) .ThenRowsSuccess(ManyDataTypesEntity.GetColumnsWithTypes())); //there are no records with BooleanType == true var rs = _manyDataTypesEntitiesTable.Where(m => m.BooleanType).Execute(); Assert.NotNull(rs); var rows = rs.ToArray(); Assert.AreEqual(0, rows.Length); var guid = Guid.NewGuid(); var data = new ManyDataTypesEntity { BooleanType = true, DateTimeOffsetType = DateTimeOffset.Now, DateTimeType = DateTime.Now, DecimalType = 10, DoubleType = 10.0, FloatType = 10.0f, GuidType = guid, IntType = 10, StringType = "Boolean True" }; TestCluster.PrimeDelete(); TestCluster.PrimeFluent( b => b.WhenQuery( "SELECT \"BooleanType\", \"DateTimeOffsetType\", \"DateTimeType\", \"DecimalType\", " + "\"DictionaryStringLongType\", \"DictionaryStringStringType\", \"DoubleType\", \"FloatType\", " + "\"GuidType\", \"Int64Type\", \"IntType\", \"ListOfGuidsType\", \"ListOfStringsType\", " + "\"NullableIntType\", \"StringType\" " + $"FROM \"{ManyDataTypesEntity.TableName}\" " + $"WHERE \"BooleanType\" = ? " + "ALLOW FILTERING", p => p.WithParams(true)) .ThenRowsSuccess( ManyDataTypesEntity.GetColumnsWithTypes(), r => r.WithRow(data.GetColumnValues()))); rs = _manyDataTypesEntitiesTable.Where(m => m.BooleanType).Execute(); Assert.NotNull(rs); rows = rs.ToArray(); Assert.AreEqual(1, rows.Length); Assert.AreEqual(guid, rows[0].GuidType); Assert.AreEqual("Boolean True", rows[0].StringType); Assert.IsTrue(rows[0].BooleanType); }
public void LinqWhere_ShortScopes() { var cqlSelect = "SELECT \"BooleanType\", \"DateTimeOffsetType\", \"DateTimeType\", \"DecimalType\", " + "\"DictionaryStringLongType\", \"DictionaryStringStringType\", \"DoubleType\", \"FloatType\", " + "\"GuidType\", \"Int64Type\", \"IntType\", \"ListOfGuidsType\", \"ListOfStringsType\", " + "\"NullableIntType\", \"StringType\" " + $"FROM \"{ManyDataTypesEntity.TableName}\" "; var guid = Guid.NewGuid(); const string pk = "Boolean True"; var data = new ManyDataTypesEntity { BooleanType = true, DateTimeOffsetType = DateTimeOffset.Now, DateTimeType = DateTime.Now, DecimalType = 11, DoubleType = 11.0, FloatType = 11.0f, GuidType = guid, IntType = 11, Int64Type = 11, StringType = pk }; //Get poco using constant short const short expectedShortValue = 11; TestCluster.PrimeFluent( b => b.WhenQuery( cqlSelect + "WHERE \"StringType\" = ? AND \"IntType\" = ? " + "ALLOW FILTERING", p => p.WithParams(pk, (int)expectedShortValue)) .ThenRowsSuccess( ManyDataTypesEntity.GetColumnsWithTypes(), r => r.WithRow(data.GetColumnValues()))); var rs = _manyDataTypesEntitiesTable .Where(m => m.StringType == pk && m.IntType == expectedShortValue).AllowFiltering().Execute(); Assert.NotNull(rs); Assert.AreEqual(1, rs.Count()); TestCluster.PrimeDelete(); TestCluster.PrimeFluent( b => b.WhenQuery( cqlSelect + "WHERE \"StringType\" = ? AND \"IntType\" = ? " + "ALLOW FILTERING", p => p.WithParams(pk, (int)expectedShortValue)) .ThenRowsSuccess( ManyDataTypesEntity.GetColumnsWithTypes(), r => r.WithRow(data.GetColumnValues()))); rs = _manyDataTypesEntitiesTable.Where(m => m.StringType == pk && m.IntType == ExpectedShortValue) .AllowFiltering().Execute(); Assert.NotNull(rs); Assert.AreEqual(1, rs.Count()); TestCluster.PrimeDelete(); TestCluster.PrimeFluent( b => b.WhenQuery( cqlSelect + "WHERE \"StringType\" = ? AND \"IntType\" = ? " + "ALLOW FILTERING", p => p.WithParams(pk, (int)expectedShortValue)) .ThenRowsSuccess( ManyDataTypesEntity.GetColumnsWithTypes(), r => r.WithRow(data.GetColumnValues()))); rs = _manyDataTypesEntitiesTable.Where(m => m.StringType == pk && ExpectedShortValue == m.IntType) .AllowFiltering().Execute(); Assert.NotNull(rs); Assert.AreEqual(1, rs.Count()); TestCluster.PrimeDelete(); TestCluster.PrimeFluent( b => b.WhenQuery( cqlSelect + "WHERE \"StringType\" = ? AND \"IntType\" = ? " + "ALLOW FILTERING", p => p.WithParams(pk, (int)expectedShortValue)) .ThenRowsSuccess( ManyDataTypesEntity.GetColumnsWithTypes(), r => r.WithRow(data.GetColumnValues()))); rs = _manyDataTypesEntitiesTable.Where(m => m.StringType == pk && expectedShortValue == m.IntType) .AllowFiltering().Execute(); Assert.NotNull(rs); Assert.AreEqual(1, rs.Count()); TestCluster.PrimeDelete(); TestCluster.PrimeFluent( b => b.WhenQuery( cqlSelect + "WHERE \"StringType\" = ? AND \"Int64Type\" = ? " + "ALLOW FILTERING", p => p.WithParams(pk, (long)expectedShortValue)) .ThenRowsSuccess( ManyDataTypesEntity.GetColumnsWithTypes(), r => r.WithRow(data.GetColumnValues()))); rs = _manyDataTypesEntitiesTable.Where(m => m.StringType == pk && m.Int64Type == expectedShortValue) .AllowFiltering().Execute(); Assert.NotNull(rs); Assert.AreEqual(1, rs.Count()); TestCluster.PrimeDelete(); TestCluster.PrimeFluent( b => b.WhenQuery( cqlSelect + "WHERE \"StringType\" = ? AND \"Int64Type\" = ? " + "ALLOW FILTERING", p => p.WithParams(pk, (long)expectedShortValue)) .ThenRowsSuccess( ManyDataTypesEntity.GetColumnsWithTypes(), r => r.WithRow(data.GetColumnValues()))); rs = _manyDataTypesEntitiesTable.Where(m => m.StringType == pk && expectedShortValue == m.Int64Type) .AllowFiltering().Execute(); Assert.NotNull(rs); Assert.AreEqual(1, rs.Count()); TestCluster.PrimeDelete(); TestCluster.PrimeFluent( b => b.WhenQuery( cqlSelect + "WHERE \"StringType\" = ? AND \"Int64Type\" = ? " + "ALLOW FILTERING", p => p.WithParams(pk, (long)expectedShortValue)) .ThenRowsSuccess( ManyDataTypesEntity.GetColumnsWithTypes(), r => r.WithRow(data.GetColumnValues()))); rs = _manyDataTypesEntitiesTable.Where(m => m.StringType == pk && m.Int64Type == ExpectedShortValue) .AllowFiltering().Execute(); Assert.NotNull(rs); Assert.AreEqual(1, rs.Count()); TestCluster.PrimeDelete(); TestCluster.PrimeFluent( b => b.WhenQuery( cqlSelect + "WHERE \"StringType\" = ? AND \"Int64Type\" = ? " + "ALLOW FILTERING", p => p.WithParams(pk, (long)expectedShortValue)) .ThenRowsSuccess( ManyDataTypesEntity.GetColumnsWithTypes(), r => r.WithRow(data.GetColumnValues()))); rs = _manyDataTypesEntitiesTable.Where(m => m.StringType == pk && ExpectedShortValue == m.Int64Type) .AllowFiltering().Execute(); Assert.NotNull(rs); Assert.AreEqual(1, rs.Count()); }