public void TestConditionMapAdd() { ConditionMap cmap = new ConditionMap(); ConditionKeyMap ckmap1 = new ConditionKeyMap("s3:prefix", "hello"); ConditionKeyMap ckmap2 = new ConditionKeyMap("s3:prefix", new HashSet <string> { "hello", "world" }); var testCases = new List <KeyValuePair <Tuple <string, ConditionKeyMap>, string> >() { // Add new key and value new KeyValuePair <Tuple <string, ConditionKeyMap>, string> (Tuple.Create <string, ConditionKeyMap>("StringEquals", ckmap1), @"{""StringEquals"":{""s3:prefix"":[""hello""]}}"), //Add existing key and value new KeyValuePair <Tuple <string, ConditionKeyMap>, string> (Tuple.Create <string, ConditionKeyMap>("StringEquals", ckmap1), @"{""StringEquals"":{""s3:prefix"":[""hello""]}}"), //Add existing key and new value new KeyValuePair <Tuple <string, ConditionKeyMap>, string> (Tuple.Create <string, ConditionKeyMap>("StringEquals", ckmap2), @"{""StringEquals"":{""s3:prefix"":[""hello"",""world""]}}"), }; int index = 0; foreach (KeyValuePair <Tuple <string, ConditionKeyMap>, string> pair in testCases) { Tuple <string, ConditionKeyMap> tuple = pair.Key; string expectedJSON = pair.Value; index += 1; cmap.Put(tuple.Item1, tuple.Item2); string cmapJSON = JsonConvert.SerializeObject(cmap, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); Assert.AreEqual(expectedJSON, cmapJSON); } }