public override void OneTimeSetUp() { base.OneTimeSetUp(); _session = Session; _session.CreateKeyspace(_uniqueKsName); _session.ChangeKeyspace(_uniqueKsName); // Create necessary tables MappingConfiguration config1 = new MappingConfiguration(); config1.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof(EntityWithTimeUuid), () => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof(EntityWithTimeUuid))); _tableEntityWithTimeUuid = new Table <EntityWithTimeUuid>(_session, config1); _tableEntityWithTimeUuid.Create(); MappingConfiguration config2 = new MappingConfiguration(); config2.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof(EntityWithNullableTimeUuid), () => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof(EntityWithNullableTimeUuid))); _tableEntityWithNullableTimeUuid = new Table <EntityWithNullableTimeUuid>(_session, config2); _tableEntityWithNullableTimeUuid.Create(); _expectedTimeUuidObjectList = EntityWithTimeUuid.GetDefaultObjectList(); for (int i = 0; i < _expectedTimeUuidObjectList.Count; i++) { _expectedTimeUuidObjectList[i].StringType = i.ToString(); } }
public override void OneTimeSetUp() { base.OneTimeSetUp(); _session = Session; _session.CreateKeyspace(_uniqueKsName); _session.ChangeKeyspace(_uniqueKsName); // Create necessary tables MappingConfiguration config1 = new MappingConfiguration(); config1.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof(EntityWithTimeUuid), () => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof(EntityWithTimeUuid))); _tableEntityWithTimeUuid = new Table <EntityWithTimeUuid>(_session, config1); _tableEntityWithTimeUuid.Create(); MappingConfiguration config2 = new MappingConfiguration(); config2.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof(EntityWithNullableTimeUuid), () => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof(EntityWithNullableTimeUuid))); _tableEntityWithNullableTimeUuid = new Table <EntityWithNullableTimeUuid>(_session, config2); _tableEntityWithNullableTimeUuid.Create(); _expectedTimeUuidObjectList = EntityWithTimeUuid.GetDefaultObjectList(); _expectedNullableTimeUuidObjectList = EntityWithNullableTimeUuid.GetDefaultObjectList(); _dateBefore = DateTimeOffset.Parse("2014-2-1"); _dateAfter = DateTimeOffset.Parse("2014-4-1"); }
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 MaxTimeUuid_GreaterThanOrEqualTo_TimeUuidComparison() { EntityWithTimeUuid.SetupEntity(_tableEntityWithTimeUuid, _expectedTimeUuidObjectList); var whereQuery = _tableEntityWithTimeUuid.Where(s => s.TimeUuidType >= CqlFunction.MaxTimeUuid(_dateBefore)); List <EntityWithTimeUuid> objectsReturned1 = whereQuery.ExecuteAsync().Result.ToList(); Assert.AreEqual(_expectedTimeUuidObjectList.Count, objectsReturned1.Count); foreach (var actualObj in objectsReturned1) { EntityWithTimeUuid.AssertListContains(_expectedTimeUuidObjectList, actualObj); } whereQuery = _tableEntityWithTimeUuid.Where(s => s.TimeUuidType >= CqlFunction.MaxTimeUuid(_dateAfter)); List <EntityWithTimeUuid> objectsReturned2 = whereQuery.ExecuteAsync().Result.ToList(); Assert.AreEqual(0, objectsReturned2.Count); }
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); }
public void MinTimeUuid_LessThan_TimeUuidComparison() { EntityWithTimeUuid.SetupEntity(_tableEntityWithTimeUuid, _expectedTimeUuidObjectList); var whereQuery = _tableEntityWithTimeUuid.Where(s => s.TimeUuidType < CqlFunction.MinTimeUuid(_dateAfter)); string whereQueryToStr = whereQuery.ToString(); Console.WriteLine(whereQueryToStr); List <EntityWithTimeUuid> objectsReturned1 = whereQuery.ExecuteAsync().Result.ToList(); Assert.AreEqual(_expectedTimeUuidObjectList.Count, objectsReturned1.Count); foreach (var actualObj in objectsReturned1) { EntityWithTimeUuid.AssertListContains(_expectedTimeUuidObjectList, actualObj); } whereQuery = _tableEntityWithTimeUuid.Where(s => s.TimeUuidType < CqlFunction.MinTimeUuid(_dateBefore)); whereQueryToStr = whereQuery.ToString(); Console.WriteLine(whereQueryToStr); List <EntityWithTimeUuid> objectsReturned2 = whereQuery.ExecuteAsync().Result.ToList(); Assert.AreEqual(0, objectsReturned2.Count); }