public void ShouldTryAndUpdateUsingFunction() { var atomic = new Atomic<int>(0); const int expected = 100; bool success = atomic.TryUpdate(x => x + expected); Assert.True(success); Assert.AreEqual(expected, atomic.Value); }
public void ShouldTryAndUpdate() { var atomic = new Atomic<int>(100); const int expected = 110; bool success = atomic.TryUpdate(expected); Assert.True(success); Assert.AreEqual(expected, atomic.Value); }
public void ShouldTryAndUpdateUsingFunction() { var atomic = new Atomic <int>(0); const int expected = 100; bool success = atomic.TryUpdate(x => x + expected); Assert.True(success); Assert.AreEqual(expected, atomic.Value); }
public void ShouldTryAndUpdate() { var atomic = new Atomic <int>(100); const int expected = 110; bool success = atomic.TryUpdate(expected); Assert.True(success); Assert.AreEqual(expected, atomic.Value); }
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); }
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); }