public void ShouldUpdateValue() { var atomic = new Atomic <int>(100); const int expected = 110; int actual = atomic.Update(expected); Assert.AreEqual(expected, actual); }
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); }
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); }
public void ShouldCallUpdateFunction() { bool called = false; var atomic = new Atomic<int>(100); atomic.Update(x => { called = true; return x; }); Assert.True(called); }
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 ShouldCallUpdateFunction() { bool called = false; var atomic = new Atomic <int>(100); atomic.Update(x => { called = true; return(x); }); Assert.True(called); }
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 ShouldUpdateValue() { var atomic = new Atomic<int>(100); const int expected = 110; int actual = atomic.Update(expected); Assert.AreEqual(expected, actual); }