public void NonExistantValuesCannotBeRetrieved()
 {
     UserDataCollection collection = new UserDataCollection();
     Assert.IsFalse(collection.HasValue(new Key<int>("key")));
     int value;
     Assert.IsFalse(collection.TryGetValue(new Key<int>("key"), out value));
     Assert.AreEqual(0, value);
     Assert.Throws<KeyNotFoundException>(delegate { collection.GetValue(new Key<int>("key"));});
     Assert.AreEqual(42, collection.GetValueOrDefault(new Key<int>("key"), 42));
 }
 public void ExistingValuesCanBeRetrieved()
 {
     UserDataCollection collection = new UserDataCollection();
     collection.SetValue(new Key<int>("key"), 123);
     Assert.IsTrue(collection.HasValue(new Key<int>("key")));
     Assert.AreEqual(123, collection.GetValue(new Key<int>("key")));
     Assert.AreEqual(123, collection.GetValueOrDefault(new Key<int>("key"), 0));
     int value;
     Assert.IsTrue(collection.TryGetValue(new Key<int>("key"), out value));
     Assert.AreEqual(123, value);
 }
        public void NonExistantValuesCannotBeRetrieved()
        {
            UserDataCollection collection = new UserDataCollection();

            Assert.IsFalse(collection.HasValue(new Key <int>("key")));
            int value;

            Assert.IsFalse(collection.TryGetValue(new Key <int>("key"), out value));
            Assert.AreEqual(0, value);
            Assert.Throws <KeyNotFoundException>(delegate { collection.GetValue(new Key <int>("key")); });
            Assert.AreEqual(42, collection.GetValueOrDefault(new Key <int>("key"), 42));
        }
        public void ExistingValuesCanBeRetrieved()
        {
            UserDataCollection collection = new UserDataCollection();

            collection.SetValue(new Key <int>("key"), 123);
            Assert.IsTrue(collection.HasValue(new Key <int>("key")));
            Assert.AreEqual(123, collection.GetValue(new Key <int>("key")));
            Assert.AreEqual(123, collection.GetValueOrDefault(new Key <int>("key"), 0));
            int value;

            Assert.IsTrue(collection.TryGetValue(new Key <int>("key"), out value));
            Assert.AreEqual(123, value);
        }