예제 #1
0
        public void ShouldUpdateValue()
        {
            var       atomic   = new Atomic <int>(100);
            const int expected = 110;
            int       actual   = atomic.Update(expected);

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
 public void ShouldUpdateUsingFunction()
 {
     var atomic = new Atomic<int>();
     const int expected = 100;
     int actual = atomic.Update(x => x + expected);
     Assert.AreEqual(expected, actual);
     Assert.AreEqual(expected, atomic.Value);
 }
예제 #3
0
        public void ShouldUpdateUsingFunction()
        {
            var       atomic   = new Atomic <int>();
            const int expected = 100;
            int       actual   = atomic.Update(x => x + expected);

            Assert.AreEqual(expected, actual);
            Assert.AreEqual(expected, atomic.Value);
        }
예제 #4
0
 public void ShouldCallUpdateFunction()
 {
     bool called = false;
     var atomic = new Atomic<int>(100);
     atomic.Update(x =>
         {
             called = true;
             return x;
         });
     Assert.True(called);
 }
예제 #5
0
 public void ConcurrentUpdateShouldFail()
 {
     var atomic = new Atomic<int>();
     var result = false;
     atomic.Update(x =>
         {
             var thread = new Thread(() => result = atomic.TryUpdate(100));
             thread.Start();
             return x;
         });
     Assert.False(result);
 }
예제 #6
0
        public void ShouldCallUpdateFunction()
        {
            bool called = false;
            var  atomic = new Atomic <int>(100);

            atomic.Update(x =>
            {
                called = true;
                return(x);
            });
            Assert.True(called);
        }
예제 #7
0
        public void ConcurrentUpdateShouldFail()
        {
            var atomic = new Atomic <int>();
            var result = false;

            atomic.Update(x =>
            {
                var thread = new Thread(() => result = atomic.TryUpdate(100));
                thread.Start();
                return(x);
            });
            Assert.False(result);
        }
예제 #8
0
 public void ShouldUpdateValue()
 {
     var atomic = new Atomic<int>(100);
     const int expected = 110;
     int actual = atomic.Update(expected);
     Assert.AreEqual(expected, actual);
 }