src/Cassandra.IntegrationTests/Linq/CqlOperatorTests/SubstractAssign.cs
/// <summary>
/// Use SubtractAssign to remove values from an array, then validate that the expected data remains in Cassandra
/// </summary>
Use SubtractAssign to remove values from an array, then validate that the expected data remains in Cassandra
Use SubtractAssign to remove values from an array then validate that the expected data remains in Cassandra
[Test]
        public void SubtractAssign_FromArray_AllValues_QueryUsingCql()
        {
            var tupleListType = EntityWithArrayType.SetupDefaultTable(Session);
            var table = tupleListType.Item1;
            var expectedEntities = tupleListType.Item2;
            var singleEntity = expectedEntities.First();
            var expectedEntity = singleEntity.Clone();
            expectedEntity.ArrayType = new string[] {};
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithArrayType { ArrayType = CqlOperator.SubstractAssign(singleEntity.ArrayType) }).Update().Execute();
            var rows = Session.Execute($"SELECT * from {table.Name} where id=\'{expectedEntity.Id}\'").GetRows().ToList();
            Assert.AreEqual(1, rows.Count);
            Assert.AreNotEqual(expectedEntity.ArrayType, singleEntity.ArrayType);
            var actualArr = rows[0].GetValue<object>("arraytype");
            Assert.AreEqual(null, actualArr);
        }
[ Test ] public void SubtractAssign_FromArray_AllValues_QueryUsingCql ( ) { var tupleListType = EntityWithArrayType . SetupDefaultTable ( Session ) ; var table = tupleListType . Item1 ; var expectedEntities = tupleListType . Item2 ; var singleEntity = expectedEntities . First ( ) ; var expectedEntity = singleEntity . Clone ( ) ; expectedEntity . ArrayType = new string [ ] { } ; table . Where ( t => t . Id == singleEntity . Id ) . Select ( t => new EntityWithArrayType { ArrayType = CqlOperator . SubstractAssign ( singleEntity . ArrayType ) } ) . Update ( ) . Execute ( ) ; var rows = Session . Execute ( $" SELECT * from  { table . Name }  where id= \' { expectedEntity . Id } \' " ) . GetRows ( ) . ToList ( ) ; Assert . AreEqual ( 1 , rows . Count ) ; Assert . AreNotEqual ( expectedEntity . ArrayType , singleEntity . ArrayType ) ; var actualArr = rows [ 0 ] . GetValue < object > ( " " ) ; Assert . AreEqual ( null , actualArr ) ; }
Use SubtractAssign to remove values from an array, then validate that the expected data remains in Cassandra
Use SubtractAssign to remove values from an array then validate that the expected data remains in Cassandra
// SubstractAssign the values // Validate final state of the data