src/Cassandra.IntegrationTests/Linq/CqlOperatorTests/SubstractAssign.cs
/// <summary>
/// Remove keys from map.
///
/// This test creates a map with 3 keys (firstey, secondkey, lastkey) whitin an entity, and removes keys from this map,
/// and check the remaining keys result
/// </summary>
Remove keys from map.

This test creates a map with 3 keys (firstey, secondkey, lastkey) whitin an entity, and removes keys from this map,
and check the remaining keys result
Remove keys from map . This test creates a map with 3 keys ( firstey secondkey lastkey ) whitin an entity and removes keys from this map and check the remaining keys result
[TestCase(2, "firstKey")]
        [TestCase(1, "firstKey", "secondKey")]
        [TestCase(0, "firstKey", "secondKey", "lastkey")]
        [TestCase(3, "unexistentKey", "unexistentKey2", "unexistentKey3")]
        [TestCase(3, new string[0])]
        [TestCassandraVersion(2, 1)]
        public void SubtractAssign_FromDictionary(int remainingKeysCount, params string[] keysToRemove)
        {
            var tupleDictionaryType = EntityWithDictionaryType.SetupDefaultTable(Session);
            var table = tupleDictionaryType.Item1;
            var newdict = new Dictionary<string, string>
            {
                { "firstKey", "firstvalue" },
                { "secondKey", "secondvalue" },
                { "lastkey", "lastvalue" },
            };
            var id = Guid.NewGuid().ToString();
            var newEntity = new EntityWithDictionaryType
            {
                Id = id,
                DictionaryType = newdict
            };
            table.Insert(newEntity).Execute();
            table.Where(t => t.Id == newEntity.Id).Select(x => new EntityWithDictionaryType
            {
                DictionaryType = x.DictionaryType.SubstractAssign(keysToRemove)
            }).Update().Execute();
            var updatedEntity = table.Where(t => t.Id == newEntity.Id).Execute().FirstOrDefault();
            Assert.NotNull(updatedEntity);
            Assert.AreEqual(remainingKeysCount, updatedEntity.DictionaryType.Count);
        }
[ TestCase ( 2 , " " ) ] [ TestCase ( 1 , " " , " " ) ] [ TestCase ( 0 , " " , " " , " " ) ] [ TestCase ( 3 , " " , " " , " " ) ] [ TestCase ( 3 , new string [ 0 ] ) ] [ TestCassandraVersion ( 2 , 1 ) ] public void SubtractAssign_FromDictionary ( int remainingKeysCount , params string [ ] keysToRemove ) { var tupleDictionaryType = EntityWithDictionaryType . SetupDefaultTable ( Session ) ; var table = tupleDictionaryType . Item1 ; var newdict = new Dictionary < string , string > { { " " , " " } , { " " , " " } , { " " , " " } , } ; var id = Guid . NewGuid ( ) . ToString ( ) ; var newEntity = new EntityWithDictionaryType { Id = id , DictionaryType = newdict } ; table . Insert ( newEntity ) . Execute ( ) ; table . Where ( t => t . Id == newEntity . Id ) . Select ( x => new EntityWithDictionaryType { DictionaryType = x . DictionaryType . SubstractAssign ( keysToRemove ) } ) . Update ( ) . Execute ( ) ; var updatedEntity = table . Where ( t => t . Id == newEntity . Id ) . Execute ( ) . FirstOrDefault ( ) ; Assert . NotNull ( updatedEntity ) ; Assert . AreEqual ( remainingKeysCount , updatedEntity . DictionaryType . Count ) ; }
Remove keys from map.
Remove keys from map .
remainingKeysCount
int