public void Ensure()
 {
     var dict = new Dictionary<string, int>();
     dict.Ensure("a", 1);
     Assert.AreEqual("([a,1])", dict.Print());
     dict.Ensure("a", 2);
     Assert.AreEqual("([a,2])", dict.Print());
 }
 public void Assoc_IsImmutable()
 {
     var dict = new Dictionary<string, int>();
     dict.Add("a", 1);
     var other = dict.Assoc("b", 2);
     Assert.AreEqual("([a,1])", dict.Print(),
         "Calling Assoc should not change the original dictionary");
 }
        public void SetVal()
        {
            var dict = new Dictionary<int, string>();
            dict.Add(1, "1");

            dict.SetVal(2, "2");
            Assert.AreEqual("([1,1],[2,2])", dict.Print());
            dict.SetVal(1, "3");
            Assert.AreEqual("([1,3],[2,2])", dict.Print());
        }
 public void Print()
 {
     var d = new Dictionary<string, object>();
     d.Ensure("foo", 1);
     d.Ensure("bar", true);
     // Note - Print should alphabetize the keys
     Assert.AreEqual("([bar,True],[foo,1])", d.Print());
 }
 public void Print()
 {
     var list = new Dictionary<string, object>[]
     {
         new Dictionary<string, object> { { "name", "George" }, { "size", 34 } },
         new Dictionary<string, object> { { "name", "Alice" }, { "size", 29 } },
         new Dictionary<string, object> { { "name", "Dan" }, { "size", 30 } },
     };
     Assert.AreEqual(
         "(([name,George],[size,34]),([name,Alice],[size,29]),([name,Dan],[size,30]))",
         list.Print());
 }
        public void For()
        {
            var idx = new Dictionary<char, int?>();
            idx.Add('a', null);
            idx.Add('b', null);
            idx.Add('c', null);

            "abc".For((i, c) => idx[c] = i);
            Assert.AreEqual("([a,0],[b,1],[c,2])", idx.Print());
        }