public void CanReleaseLockIfLockAquired() { using (var aggregateLock = new AggregateLock(typeof(Aggregate), GuidStrategy.NewGuid())) { aggregateLock.Aquire(); aggregateLock.Release(); Assert.False(aggregateLock.Aquired); } }
public void CannotReleaseLockIfLockNotAquired() { var aggregateId = GuidStrategy.NewGuid(); using (var aggregateLock = new AggregateLock(typeof(Aggregate), aggregateId)) { var ex = Assert.Throws <InvalidOperationException>(() => aggregateLock.Release()); Assert.Equal(Exceptions.AggregateLockNotHeld.FormatWith(typeof(Aggregate), aggregateId), ex.Message); } }
public void CannotReleaseLockIfLockNotAquired() { var aggregateId = GuidStrategy.NewGuid(); using (var aggregateLock = new AggregateLock(typeof(Aggregate), aggregateId)) { var ex = Assert.Throws<InvalidOperationException>(() => aggregateLock.Release()); Assert.Equal(Exceptions.AggregateLockNotHeld.FormatWith(typeof(Aggregate), aggregateId), ex.Message); } }