Example #1
0
 public void GetValueOrCreate_ReturnsOldValue()
 {
     var s = new Dictionary<string, List<int>> () {
         { "foo", new List<int> {42} },
     };
     AssertAreSame (new[]{42}, s.GetValueOrCreate ("foo"));
     AssertAreSame (new[]{42}, s.GetValueOrCreate ("foo", () => new List<int> {1}));
 }
Example #2
0
 public void GetValueOrCreate_ReturnsNewValue()
 {
     var s = new Dictionary<string, List<int>>();
     Assert.AreEqual (new List<int>(), s.GetValueOrCreate ("foo"));
     List<int> v = null;
     var r = s.GetValueOrCreate ("bar", () => v = new List<int> ());
     Assert.AreSame (r, v);
 }