コード例 #1
0
        public void update_value_with_action_when_key_exist()
        {
            Test1 t = new Test1 { Value = 555 };
            var key = Guid.NewGuid();
            _guidKeyClassWriter.Add(key, t);
            var newValue = _guidKeyClassWriter.UpdateOrThrow(key, tv =>
            {
                tv.Value += 1;
            });


            Assert.AreEqual(556, newValue.Value);
        }
コード例 #2
0
 public void add_value_when_key_exist()
 {
     Test1 t = new Test1 { Value = 555 };
     var key = Guid.NewGuid();
     _guidKeyClassWriter.Add(key, t);
     _guidKeyClassWriter.Add(key, t);
 }
コード例 #3
0
        public void when_key_exist_not_call_new_view_func_and_call_action_and_get_new_value()
        {
            Test1 t = new Test1 { Value = 555 };
            var key = Guid.NewGuid();
            _guidKeyClassWriter.AddOrUpdate(key, t, tv => { tv.Value += 1; });
            var newValue = _guidKeyClassWriter.AddOrUpdate(key, () => t, tv => { tv.Value += 1; });

            Assert.AreEqual(typeof(Test1), newValue.GetType());
            Assert.AreEqual(556, newValue.Value);
        }
コード例 #4
0
        public void add_new_value()
        {
            Test1 t = new Test1 { Value = 555 };
            var newValue = _guidKeyClassWriter.Add(Guid.NewGuid(), t);

            Assert.AreEqual(t, newValue);
            Assert.AreEqual(555, newValue.Value);
        }
コード例 #5
0
        public void when_not_found_key_get_new_view_func_and_not_call_action()
        {
            Test1 t = new Test1 { Value = 555 };
            var key = Guid.NewGuid();
            var newValue = _guidKeyClassWriter.AddOrUpdate(key, () => t, tv => { tv.Value += 1; });

            Assert.AreEqual(t, newValue);
            Assert.AreEqual(555, newValue.Value);
        }