public void ExecutePaged_Where_Fetches_Following_Pages() { const int pageSize = 5; var table = GetTable(); var fullList = new HashSet <Guid>(); var page = table.Where(s => CqlFunction.Token(s.Id) > long.MinValue).SetPageSize(pageSize).ExecutePaged(); Assert.AreEqual(pageSize, page.Count); foreach (var s in page) { fullList.Add(s.Id); } var safeCounter = 0; while (page.PagingState != null && safeCounter++ < TotalRows) { page = table.Where(s => CqlFunction.Token(s.Id) > long.MinValue).SetPageSize(pageSize).SetPagingState(page.PagingState).ExecutePaged(); Assert.LessOrEqual(page.Count, pageSize); foreach (var s in page) { fullList.Add(s.Id); } } Assert.AreEqual(TotalRows, fullList.Count); }
public void ExecutePaged_Where_Fetches_Only_PageSize() { const int pageSize = 10; var table = GetTable(); var page = table.Where(s => CqlFunction.Token(s.Id) > long.MinValue).SetPageSize(pageSize).ExecutePaged(); Assert.AreEqual(pageSize, page.Count); Assert.AreEqual(pageSize, page.Count()); }
public void Token_LessThan_String() { EntityWithTimeUuid.SetupEntity(_tableEntityWithTimeUuid, _expectedTimeUuidObjectList); List <EntityWithTimeUuid> listAsTheyAreInCassandra = _tableEntityWithTimeUuid.Execute().ToList(); Assert.AreEqual(_expectedTimeUuidObjectList.Count, listAsTheyAreInCassandra.Count); for (int i = 0; i < listAsTheyAreInCassandra.Count; i++) { EntityWithTimeUuid singleEntity = listAsTheyAreInCassandra[i]; var whereQuery = _tableEntityWithTimeUuid.Where(s => CqlFunction.Token(s.StringType) < CqlFunction.Token(singleEntity.StringType)); List <EntityWithTimeUuid> objectsReturned1 = whereQuery.ExecuteAsync().Result.ToList(); Assert.AreEqual(i, objectsReturned1.Count); foreach (var actualObj in objectsReturned1) { EntityWithTimeUuid.AssertListContains(_expectedTimeUuidObjectList, actualObj); } } }
public void Token_Function_Linq_Test() { string query = null; object[] parameters = null; var session = GetSession((q, v) => { query = q; parameters = v; }); //This time is case sensitive var table = GetTable<AllTypesEntity>(session, new Map<AllTypesEntity>().TableName("tbl3").CaseSensitive()); var key = "key1"; table.Where(t => CqlFunction.Token(t.StringValue) > CqlFunction.Token(key)).Execute(); Assert.AreEqual(@"SELECT ""BooleanValue"", ""DateTimeValue"", ""DecimalValue"", ""DoubleValue"", ""Int64Value"", ""IntValue"", ""StringValue"", ""UuidValue"" FROM ""tbl3"" WHERE token(""StringValue"") > token(?)", query); Assert.AreEqual(key, parameters[0]); table.Where(t => CqlFunction.Token(t.StringValue, t.Int64Value) <= CqlFunction.Token(key, "key2")).Execute(); Assert.AreEqual(@"SELECT ""BooleanValue"", ""DateTimeValue"", ""DecimalValue"", ""DoubleValue"", ""Int64Value"", ""IntValue"", ""StringValue"", ""UuidValue"" FROM ""tbl3"" WHERE token(""StringValue"", ""Int64Value"") <= token(?, ?)", query); Assert.AreEqual(key, parameters[0]); Assert.AreEqual("key2", parameters[1]); }
public void Token_EqualTo_String() { EntityWithTimeUuid.SetupEntity(_tableEntityWithTimeUuid, _expectedTimeUuidObjectList); foreach (EntityWithTimeUuid singleEntity in _expectedTimeUuidObjectList) { var whereQuery = _tableEntityWithTimeUuid.Where(s => CqlFunction.Token(s.StringType) == CqlFunction.Token(singleEntity.StringType)); List <EntityWithTimeUuid> objectsReturned1 = whereQuery.ExecuteAsync().Result.ToList(); Assert.AreEqual(1, objectsReturned1.Count); EntityWithTimeUuid.AssertEquals(singleEntity, objectsReturned1.First()); foreach (var actualObj in objectsReturned1) { EntityWithTimeUuid.AssertListContains(_expectedTimeUuidObjectList, actualObj); } } // change to query that returns nothing var whereQueryReturnsNothing = _tableEntityWithTimeUuid.Where(s => CqlFunction.Token(s.StringType) == CqlFunction.Token(Guid.NewGuid().ToString())); List <EntityWithTimeUuid> objectsReturned2 = whereQueryReturnsNothing.ExecuteAsync().Result.ToList(); Assert.AreEqual(0, objectsReturned2.Count); }