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);
        }
        public void ResetFamily(CassandraColumnFamily family = null)
        {
            family = family ?? Family;

            family.RemoveAllRows();

            family.InsertColumn(TestKey1, "Test1", Math.PI);
            family.InsertColumn(TestKey1, "Test2", Math.PI);
            family.InsertColumn(TestKey1, "Test3", Math.PI);

            family.InsertColumn(TestKey2, "Test1", Math.PI);
            family.InsertColumn(TestKey2, "Test2", Math.PI);
            family.InsertColumn(TestKey2, "Test3", Math.PI);
        }
        public void ResetUsersFamily(CassandraColumnFamily userFamily = null)
        {
            userFamily = userFamily ?? UserFamily;

            var db = userFamily.Context;

            userFamily.RemoveAllRows();

            foreach (var user in Users)
            {
                var insertQuery = @"INSERT INTO ""Users"" (Id, Name, Email, Age) VALUES (" + user.Id + ", '" + user.Name + "', '" + user.Email + "', " + user.Age + ")";
                db.ExecuteNonQuery(insertQuery);
            }
        }
        public _CassandraSetup()
        {
            var keyspaceName = "Testing";
            var server = new Server("localhost");

            if (CassandraSession.KeyspaceExists(server, keyspaceName))
                CassandraSession.DropKeyspace(server, keyspaceName);

            var keyspace = new CassandraKeyspace(keyspaceName);
            keyspace.TryCreateSelf(server);
            keyspace.TryCreateColumnFamily<AsciiType>(server, "Standard");
            keyspace.TryCreateColumnFamily<AsciiType, AsciiType>(server, "Super");
            keyspace.TryCreateColumnFamily<AsciiType>(server, "StandardAsciiType");
            keyspace.TryCreateColumnFamily<BytesType>(server, "StandardBytesType");
            keyspace.TryCreateColumnFamily<IntegerType>(server, "StandardIntegerType");
            keyspace.TryCreateColumnFamily<LexicalUUIDType>(server, "StandardLexicalUUIDType");
            keyspace.TryCreateColumnFamily<LongType>(server, "StandardLongType");
            keyspace.TryCreateColumnFamily<TimeUUIDType>(server, "StandardTimeUUIDType");
            keyspace.TryCreateColumnFamily<UTF8Type>(server, "StandardUTF8Type");
            keyspace.TryCreateColumnFamily<UUIDType>(server, "StandardUUIDType");
            keyspace.TryCreateColumnFamily<CompositeType<LongType, UTF8Type>>(server, "StandardCompositeType");
            keyspace.TryCreateColumnFamily<DynamicCompositeType>(server, "StandardDynamicCompositeType");

            DB = new CassandraContext(keyspaceName, server);
            DB.ThrowErrors = true;

            Family = DB.GetColumnFamily<AsciiType>("Standard");
            SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");

            Family.RemoveAllRows();
            SuperFamily.RemoveAllRows();

            Family.InsertColumn(TestKey1, "Test1", Math.PI);
            Family.InsertColumn(TestKey1, "Test2", Math.PI);
            Family.InsertColumn(TestKey1, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

            Family.InsertColumn(TestKey2, "Test1", Math.PI);
            Family.InsertColumn(TestKey2, "Test2", Math.PI);
            Family.InsertColumn(TestKey2, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);
        }
        public void ResetUsersFamily(CassandraColumnFamily userFamily = null)
        {
            userFamily = userFamily ?? UserFamily;

            var db = userFamily.Context;

            userFamily.RemoveAllRows();

            foreach (var user in Users)
            {
                dynamic record = userFamily.CreateRecord(user.Id);
                record.Name  = user.Name;
                record.Email = user.Email;
                record.Age   = user.Age;

                db.Attach(record);
            }

            db.SaveChanges();
        }
		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);
		}
		public void ResetFamily(CassandraColumnFamily family = null)
		{
			family = family ?? Family;

			family.RemoveAllRows();

			family.InsertColumn(TestKey1, "Test1", Math.PI);
			family.InsertColumn(TestKey1, "Test2", Math.PI);
			family.InsertColumn(TestKey1, "Test3", Math.PI);

			family.InsertColumn(TestKey2, "Test1", Math.PI);
			family.InsertColumn(TestKey2, "Test2", Math.PI);
			family.InsertColumn(TestKey2, "Test3", Math.PI);
		}
		public void ResetUsersFamily(CassandraColumnFamily userFamily = null)
		{
			userFamily = userFamily ?? UserFamily;

			var db = userFamily.Context;
			userFamily.RemoveAllRows();

			foreach (var user in Users)
			{
				dynamic record = userFamily.CreateRecord(user.Id);
				record.Name = user.Name;
				record.Email = user.Email;
				record.Age = user.Age;

				db.Attach(record);
			}

			db.SaveChanges();
		}
Esempio n. 9
0
        public _CassandraSetup()
        {
            var keyspaceName = "Testing";
            var server = new Server("localhost");

            if (!CassandraSession.KeyspaceExists(server, keyspaceName))
                CassandraSession.AddKeyspace(server, new KsDef {
                    Name = "Testing",
                    Replication_factor = 1,
                    Strategy_class = "org.apache.cassandra.locator.SimpleStrategy",
                    Cf_defs = new List<CfDef>()
                });

            var keyspace = new CassandraKeyspace(keyspaceName);

            if (!keyspace.ColumnFamilyExists(server, "Standard"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "Standard",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "AsciiType",
                    Comment = "Used for testing Standard family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardAsciiType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardAsciiType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "AsciiType",
                    Comment = "Used for testing Standard family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardBytesType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardBytesType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "BytesType",
                    Comment = "Used for testing BytesType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardIntegerType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardIntegerType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "IntegerType",
                    Comment = "Used for testing IntegerType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardLexicalUUIDType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardLexicalUUIDType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "LexicalUUIDType",
                    Comment = "Used for testing LexicalUUIDType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardLongType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardLongType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "LongType",
                    Comment = "Used for testing LongType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardTimeUUIDType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardTimeUUIDType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "TimeUUIDType",
                    Comment = "Used for testing TimeUUIDType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardUTF8Type"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardUTF8Type",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "UTF8Type",
                    Comment = "Used for testing UTF8Type family."
                });

            if (!keyspace.ColumnFamilyExists(server, "Super"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "Super",
                    Keyspace = "Testing",
                    Column_type = "Super",
                    Comparator_type = "AsciiType",
                    Subcomparator_type = "AsciiType",
                    Comment = "Used for testing Super family."
                });

            DB = new CassandraContext(keyspaceName, server);
            DB.ThrowErrors = true;

            Family = DB.GetColumnFamily<AsciiType>("Standard");
            SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");

            Family.RemoveAllRows();
            SuperFamily.RemoveAllRows();

            Family.InsertColumn(TestKey1, "Test1", Math.PI);
            Family.InsertColumn(TestKey1, "Test2", Math.PI);
            Family.InsertColumn(TestKey1, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

            Family.InsertColumn(TestKey2, "Test1", Math.PI);
            Family.InsertColumn(TestKey2, "Test2", Math.PI);
            Family.InsertColumn(TestKey2, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);
        }
        public _CassandraSetup()
        {
            var keyspaceName = "Testing";
            var server       = new Server("localhost");

            if (!CassandraSession.KeyspaceExists(server, keyspaceName))
            {
                CassandraSession.AddKeyspace(server, new KsDef {
                    Name = "Testing",
                    Replication_factor = 1,
                    Strategy_class     = "org.apache.cassandra.locator.SimpleStrategy",
                    Cf_defs            = new List <CfDef>()
                });
            }

            var keyspace = new CassandraKeyspace(keyspaceName);

            if (!keyspace.ColumnFamilyExists(server, "Standard"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "Standard",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "AsciiType",
                    Comment         = "Used for testing Standard family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardAsciiType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardAsciiType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "AsciiType",
                    Comment         = "Used for testing Standard family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardBytesType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardBytesType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "BytesType",
                    Comment         = "Used for testing BytesType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardIntegerType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardIntegerType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "IntegerType",
                    Comment         = "Used for testing IntegerType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardLexicalUUIDType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardLexicalUUIDType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "LexicalUUIDType",
                    Comment         = "Used for testing LexicalUUIDType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardLongType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardLongType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "LongType",
                    Comment         = "Used for testing LongType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardTimeUUIDType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardTimeUUIDType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "TimeUUIDType",
                    Comment         = "Used for testing TimeUUIDType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardUTF8Type"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardUTF8Type",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "UTF8Type",
                    Comment         = "Used for testing UTF8Type family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "Super"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name               = "Super",
                    Keyspace           = "Testing",
                    Column_type        = "Super",
                    Comparator_type    = "AsciiType",
                    Subcomparator_type = "AsciiType",
                    Comment            = "Used for testing Super family."
                });
            }

            DB             = new CassandraContext(keyspaceName, server);
            DB.ThrowErrors = true;

            Family      = DB.GetColumnFamily <AsciiType>("Standard");
            SuperFamily = DB.GetColumnFamily <AsciiType, AsciiType>("Super");

            Family.RemoveAllRows();
            SuperFamily.RemoveAllRows();

            Family.InsertColumn(TestKey1, "Test1", Math.PI);
            Family.InsertColumn(TestKey1, "Test2", Math.PI);
            Family.InsertColumn(TestKey1, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

            Family.InsertColumn(TestKey2, "Test1", Math.PI);
            Family.InsertColumn(TestKey2, "Test2", Math.PI);
            Family.InsertColumn(TestKey2, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);
        }
		public void ResetUsersFamily(CassandraColumnFamily userFamily = null)
		{
			userFamily = userFamily ?? UserFamily;

			var db = userFamily.Context;
			userFamily.RemoveAllRows();

			foreach (var user in Users)
			{
                var insertQuery = @"INSERT INTO ""Users"" (Id, Name, Email, Age) VALUES ("+ user.Id +", '" + user.Name + "', '"+ user.Email +"', "+ user.Age +")";
                db.ExecuteNonQuery(insertQuery);
			}
		}