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_BooleanScopes() { //Get no records const bool all = true; 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(all)) .ThenRowsSuccess(ManyDataTypesEntity.GetColumnsWithTypes())); var rs = _manyDataTypesEntitiesTable.Where(m => m.BooleanType == all).Execute(); Assert.NotNull(rs); Assert.AreEqual(0, rs.Count()); //get all records 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(false)) .ThenRowsSuccess( ManyDataTypesEntity.GetColumnsWithTypes(), r => r.WithRow(_manyDataTypesEntitiesList.First().GetColumnValues()))); rs = _manyDataTypesEntitiesTable.Where(m => m.BooleanType == bool.Parse("false")).Execute(); Assert.NotNull(rs); Assert.AreEqual(1, rs.Count()); }