public void TryEnd_Disposed_ReturnsFalse() { var era = new Era(); era.Dispose(); Assert.That(!era.TryEnd()); }
public void TryEnd_NotEnded_ReturnsTrue() { using (var era = new Era()) { Assert.That(era.TryEnd()); Assert.That(era.HasEnded); } }
public static Era Ended() { var era = new Era(); var ok = era.TryEnd(); Ensure.That(ok, @"Era contested."); return(era); }
/// <summary> /// Attempt to set the condition. /// </summary> /// <returns> /// <see langword="true"/> if the condition was set; <see langword="false"/> if it was /// already set or disposed. /// </returns> public bool TrySet() { // NOTE: Exception cannot be thrown. // ReSharper disable once ExceptionNotDocumented if (Interlocked.CompareExchange( ref FValue, C_True, C_False) != C_False) { return(false); } return(FCurrent.TryEnd()); }