src/Cassandra.IntegrationTests/Linq/CqlOperatorTests/SubstractAssign.cs
/// <summary>
/// Validate that SubractAssign does not change the list when attempting to remove a value that is not contained in the list
/// </summary>
Validate that SubractAssign does not change the list when attempting to remove a value that is not contained in the list
Validate that SubractAssign does not change the list when attempting to remove a value that is not contained in the list
[Test]
        public void SubtractAssign_FromArray_ValNotInArray()
        {
            var tupleArrayType = EntityWithArrayType.SetupDefaultTable(Session);
            var table = tupleArrayType.Item1;
            var expectedEntities = tupleArrayType.Item2;
            var singleEntity = expectedEntities.First();
            string[] valsToDelete = { "9999" };
            Assert.AreEqual(1, singleEntity.ArrayType.Length);
            Assert.AreNotEqual(valsToDelete[0], singleEntity.ArrayType[0]);
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithArrayType { ArrayType = CqlOperator.SubstractAssign(valsToDelete) }).Update().Execute();
            var rows = Session.Execute($"SELECT * from {table.Name} where id=\'{singleEntity.Id}\'").GetRows().ToList();
            Assert.AreEqual(1, rows.Count);
            var actualArr = rows[0].GetValue<object>("arraytype");
            Assert.AreEqual(singleEntity.ArrayType, actualArr);
        }
[ Test ] public void SubtractAssign_FromArray_ValNotInArray ( ) { var tupleArrayType = EntityWithArrayType . SetupDefaultTable ( Session ) ; var table = tupleArrayType . Item1 ; var expectedEntities = tupleArrayType . Item2 ; var singleEntity = expectedEntities . First ( ) ; string [ ] valsToDelete = { " " } ; Assert . AreEqual ( 1 , singleEntity . ArrayType . Length ) ; Assert . AreNotEqual ( valsToDelete [ 0 ] , singleEntity . ArrayType [ 0 ] ) ; table . Where ( t => t . Id == singleEntity . Id ) . Select ( t => new EntityWithArrayType { ArrayType = CqlOperator . SubstractAssign ( valsToDelete ) } ) . Update ( ) . Execute ( ) ; var rows = Session . Execute ( $" SELECT * from  { table . Name }  where id= \' { singleEntity . Id } \' " ) . GetRows ( ) . ToList ( ) ; Assert . AreEqual ( 1 , rows . Count ) ; var actualArr = rows [ 0 ] . GetValue < object > ( " " ) ; Assert . AreEqual ( singleEntity . ArrayType , actualArr ) ; }
Validate that SubractAssign does not change the list when attempting to remove a value that is not contained in the list
Validate that SubractAssign does not change the list when attempting to remove a value that is not contained in the list
// make sure this value is not in the array  // SubstractAssign the values // Validate final state of the data