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_FromList_ValNotInList()
        {
            var tupleListType = EntityWithListType.SetupDefaultTable(Session);
            var table = tupleListType.Item1;
            var expectedEntities = tupleListType.Item2;
            var singleEntity = expectedEntities.First();
            var valsToDelete = new List<int>() { 9999 };
            Assert.IsFalse(singleEntity.ListType.Contains(valsToDelete.First()));
            table.Where(t => t.Id == singleEntity.Id).Select(t => new EntityWithListType { ListType = CqlOperator.SubstractAssign(valsToDelete) }).Update().Execute();
            var entityList = table.Where(m => m.Id == singleEntity.Id).ExecuteAsync().Result.ToList();
            Assert.AreEqual(1, entityList.Count);
            singleEntity.AssertEquals(entityList[0]);
        }
[ Test ] public void SubtractAssign_FromList_ValNotInList ( ) { var tupleListType = EntityWithListType . SetupDefaultTable ( Session ) ; var table = tupleListType . Item1 ; var expectedEntities = tupleListType . Item2 ; var singleEntity = expectedEntities . First ( ) ; var valsToDelete = new List < int > ( ) { 9999 } ; Assert . IsFalse ( singleEntity . ListType . Contains ( valsToDelete . First ( ) ) ) ; table . Where ( t => t . Id == singleEntity . Id ) . Select ( t => new EntityWithListType { ListType = CqlOperator . SubstractAssign ( valsToDelete ) } ) . Update ( ) . Execute ( ) ; var entityList = table . Where ( m => m . Id == singleEntity . Id ) . ExecuteAsync ( ) . Result . ToList ( ) ; Assert . AreEqual ( 1 , entityList . Count ) ; singleEntity . AssertEquals ( entityList [ 0 ] ) ; }
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 list // SubstractAssign the values // Validate final state of the data