コード例 #1
0
        public void UpdateOrThrow()
        {
            var target = new ConcurrentIndexed <int, string>();

            Assert.ThrowsAny <Exception>(() => target.UpdateOrThrow(1, x => x + "!"));
            target.Set(1, "1");
            Assert.Equal("1!", target.UpdateOrThrow(1, x => x + "!"));
        }
コード例 #2
0
        public void SetOrThrow()
        {
            var target = new ConcurrentIndexed <int, string>();

            Assert.ThrowsAny <Exception>(() => target.UpdateOrThrow(1, "1"));

            target.AddOrThrow(1, "1");
            target.UpdateOrThrow(1, "1-1");

            Assert.Equal("1-1", target.GetOrThrow(1));
        }
コード例 #3
0
        public void AddUpdateOrThrow(int i)
        {
            var thing = new ConcurrentIndexed <int, string>();

            thing.AddOrThrow(i, "hello");
            Assert.Equal("hello", thing.GetOrThrow(i));
            Assert.Throws <Exception>(() =>
            {
                thing.AddOrThrow(i, "hello");
            });

            thing.UpdateOrThrow(i, (s) => s + " world");
            Assert.Equal("hello world", thing.GetOrThrow(i));
        }