public void NoInput() { DeleteCommand cmd = new DeleteCommand(); try { using (IAquilesConnection connection = AquilesHelper.RetrieveConnection("Keyspace1")) { connection.Execute(cmd); } Assert.Fail(); } catch (AquilesCommandParameterException) { // this is supposed to happen } }
public void NotExistingColumnFamily() { DeleteCommand cmd = new DeleteCommand(); cmd.KeySpace = "Keyspace1"; cmd.ColumnFamily = "Standard12"; cmd.Key = "test"; cmd.Column = new Aquiles.Model.AquilesColumn() { ColumnName = "zarasa" }; try { using (IAquilesConnection connection = AquilesHelper.RetrieveConnection("Keyspace1")) { connection.Execute(cmd); } Assert.Fail(); } catch (AquilesCommandParameterException) { // this is supposed to happen } }
public void OnlyKeySpaceColumn() { DeleteCommand cmd = new DeleteCommand(); cmd.KeySpace = "Keyspace1"; cmd.Column = new Aquiles.Model.AquilesColumn() { ColumnName = "columnName" }; try { using (IAquilesConnection connection = AquilesHelper.RetrieveConnection("Keyspace1")) { connection.Execute(cmd); } Assert.Fail(); } catch (AquilesCommandParameterException) { // this is supposed to happen } }
public void OnlyColumnFamilyKey() { DeleteCommand cmd = new DeleteCommand(); cmd.Key = "zarasa"; cmd.ColumnFamily = "Standard1"; try { using (IAquilesConnection connection = AquilesHelper.RetrieveConnection("Keyspace1")) { connection.Execute(cmd); } Assert.Fail(); } catch (AquilesCommandParameterException) { // this is supposed to happen } }
private static void DoTestInsertDeleteAndGetOnSameConnection(string columnFamily, string keyspace, string key, string columnName, string columnValue) { // Insert statement InsertCommand insertCommand = new InsertCommand(); insertCommand.KeySpace = keyspace; insertCommand.ColumnFamily = columnFamily; insertCommand.Key = key; insertCommand.Column = new Aquiles.Model.AquilesColumn() { ColumnName = columnName, Value = columnValue }; // Get statement GetCommand getCommand = new GetCommand(); getCommand.KeySpace = keyspace; getCommand.Key = key; getCommand.ColumnFamily = columnFamily; getCommand.ColumnName = columnName; //Delete statement DeleteCommand delCommand = new DeleteCommand(); delCommand.KeySpace = keyspace; delCommand.Key = key; delCommand.ColumnFamily = columnFamily; using (IAquilesConnection connection = AquilesHelper.RetrieveConnection("Keyspace1")) { connection.Open(); connection.Execute(insertCommand); connection.Execute(getCommand); GetCommand.Out output = getCommand.Output; Assert.IsNotNull(output); Assert.IsNotNull(output.Column); Assert.IsTrue(columnName.CompareTo(output.Column.ColumnName) == 0); Assert.IsTrue(columnValue.CompareTo(output.Column.Value) == 0); delCommand.Column = output.Column; connection.Execute(delCommand); connection.Execute(getCommand); connection.Close(); Assert.IsNull(getCommand.Output); } }
private static void DoInsertDeleteAndGetOnDifferenteConnections(string columnFamily, string keyspace, string key, string columnName, string columnValue) { // Insert statement InsertCommand insertCommand = new InsertCommand(); insertCommand.KeySpace = keyspace; insertCommand.ColumnFamily = columnFamily; insertCommand.Key = key; insertCommand.Column = new Aquiles.Model.AquilesColumn() { ColumnName = columnName, Value = columnValue }; using (IAquilesConnection connection = AquilesHelper.RetrieveConnection("Keyspace1")) { connection.Execute(insertCommand); } // Get statement GetCommand getCommand = new GetCommand(); getCommand.KeySpace = keyspace; getCommand.Key = key; getCommand.ColumnFamily = columnFamily; getCommand.ColumnName = columnName; using (IAquilesConnection connection = AquilesHelper.RetrieveConnection("Keyspace1")) { connection.Execute(getCommand); } GetCommand.Out output = getCommand.Output; Assert.IsNotNull(output); Assert.IsNotNull(output.Column); Assert.IsTrue(columnName.CompareTo(output.Column.ColumnName) == 0); Assert.IsTrue(columnValue.CompareTo(output.Column.Value) == 0); //Delete statement DeleteCommand delCommand = new DeleteCommand(); delCommand.KeySpace = keyspace; delCommand.Key = key; delCommand.ColumnFamily = columnFamily; delCommand.Column = output.Column; using (IAquilesConnection connection = AquilesHelper.RetrieveConnection("Keyspace1")) { connection.Execute(delCommand); } // get statement to see if it was actually deleted (get is already created, then i am reusing) using (IAquilesConnection connection = AquilesHelper.RetrieveConnection("Keyspace1")) { connection.Execute(getCommand); } Assert.IsNull(getCommand.Output); }
public void TestBatchMutation() { Guid id = Guid.NewGuid(); BatchMutateCommand cmd = new BatchMutateCommand(); cmd.KeySpace = "Keyspace1"; Dictionary<string, Dictionary<string, List<IAquilesMutation>>> keyMutations = new Dictionary<string, Dictionary<string, List<IAquilesMutation>>>(); Dictionary<string,List<IAquilesMutation>> columnMutation = new Dictionary<string,List<IAquilesMutation>>(); List<IAquilesMutation> mutations = new List<IAquilesMutation>(); AquilesSetMutation insertContextDataMutation = new AquilesSetMutation(); insertContextDataMutation.SuperColumn = new AquilesSuperColumn() { Name = "Data", Columns = new List<AquilesColumn>() }; insertContextDataMutation.SuperColumn.Columns.Add(this.CreateColumn("Created", DateTime.UtcNow)); insertContextDataMutation.SuperColumn.Columns.Add(this.CreateColumn("LockDate", DateTime.UtcNow)); insertContextDataMutation.SuperColumn.Columns.Add(this.CreateColumn("LockID", 0)); insertContextDataMutation.SuperColumn.Columns.Add(this.CreateColumn("Locked", false)); insertContextDataMutation.SuperColumn.Columns.Add(this.CreateColumn("Flags", 0)); mutations.Add(this.CreateSessionDataInsert()); mutations.Add(insertContextDataMutation); columnMutation.Add("Super1", mutations); string key = id.ToString(); keyMutations.Add(key, columnMutation); cmd.Mutations = keyMutations; GetSliceCommand getSliceCmd = new GetSliceCommand() { KeySpace = "Keyspace1", ColumnFamily = "Super1", Key = key, Predicate = new AquilesSlicePredicate() { SliceRange = new AquilesSliceRange() { Count = int.MaxValue, Reversed = true } } }; DeleteCommand delCommand = new DeleteCommand() { KeySpace = "Keyspace1", ColumnFamily = "Super1", Key = key }; using (IAquilesConnection connection = AquilesHelper.RetrieveConnection("Keyspace1")) { connection.Open(); connection.Execute(cmd); connection.Execute(getSliceCmd); connection.Execute(delCommand); connection.Close(); } }