Skip to content
Browse files

Added a CounterColumnFamily to the DatabaseSetup

  • Loading branch information...
1 parent cce150d commit a6e3f52fdd396c8cfddb6bb209cf3ce92851abfa @Aaronontheweb Aaronontheweb committed
Showing with 27 additions and 0 deletions.
  1. +27 −0 test/FluentCassandra.Tests/CassandraDatabaseSetup.cs
View
27 test/FluentCassandra.Tests/CassandraDatabaseSetup.cs
@@ -13,8 +13,11 @@ public class CassandraDatabaseSetup
public CassandraContext DB;
public CassandraColumnFamily<AsciiType> Family;
+
public CassandraSuperColumnFamily<AsciiType, AsciiType> SuperFamily;
+
public CassandraColumnFamily UserFamily;
+ public CassandraColumnFamily CounterFamily;
public User[] Users = new[] {
new User { Id = 1, Name = "Darren Gemmell", Email = "darren@somewhere.com", Age = 32 },
@@ -51,6 +54,7 @@ public CassandraDatabaseSetup(bool reset = false)
Family = DB.GetColumnFamily<AsciiType>("Standard");
SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");
UserFamily = DB.GetColumnFamily("Users");
+ CounterFamily = DB.GetColumnFamily("Counters");
if (exists && !reset)
return;
@@ -82,6 +86,12 @@ public void ResetDatabase()
keyspace.TryCreateColumnFamily<TimeUUIDType>("StandardTimeUUIDType");
keyspace.TryCreateColumnFamily<UTF8Type>("StandardUTF8Type");
keyspace.TryCreateColumnFamily<UUIDType>("StandardUUIDType");
+ keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema()
+ {
+ FamilyName = "Counter",
+ ColumnNameType = CassandraType.UTF8Type,
+ DefaultColumnValueType = CassandraType.CounterColumnType
+ });
keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema {
FamilyName = "StandardDecimalType",
ColumnNameType = CassandraType.DecimalType
@@ -108,10 +118,12 @@ Age int
var family = db.GetColumnFamily<AsciiType>("Standard");
var superFamily = db.GetColumnFamily<AsciiType, AsciiType>("Super");
var userFamily = db.GetColumnFamily("Users");
+ var counterFamily = db.GetColumnFamily("Counters");
ResetFamily(family);
ResetSuperFamily(superFamily);
ResetUsersFamily(userFamily);
+ ResetCounterColumnFamily(counterFamily);
}
}
@@ -164,5 +176,20 @@ public void ResetSuperFamily(CassandraSuperColumnFamily superFamily = null)
superFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
superFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);
}
+
+ public void ResetCounterColumnFamily(CassandraColumnFamily counterFamily = null)
+ {
+ counterFamily = counterFamily ?? CounterFamily;
+
+ counterFamily.RemoveAllRows();
+
+ counterFamily.InsertCounterColumn(TestKey1, "Test1", 1);
+ counterFamily.InsertCounterColumn(TestKey1, "Test2", 2);
+ counterFamily.InsertCounterColumn(TestKey1, "Test3", 3);
+
+ counterFamily.InsertCounterColumn(TestKey2, "Test1", 2);
+ counterFamily.InsertCounterColumn(TestKey2, "Test2", 4);
+ counterFamily.InsertCounterColumn(TestKey2, "Test3", 6);
+ }
}
}

0 comments on commit a6e3f52

Please sign in to comment.
Something went wrong with that request. Please try again.