Beispiel #1
0
        public void TryEnd_Disposed_ReturnsFalse()
        {
            var era = new Era();

            era.Dispose();

            Assert.That(!era.TryEnd());
        }
Beispiel #2
0
 public void TryEnd_NotEnded_ReturnsTrue()
 {
     using (var era = new Era())
     {
         Assert.That(era.TryEnd());
         Assert.That(era.HasEnded);
     }
 }
Beispiel #3
0
        public static Era Ended()
        {
            var era = new Era();
            var ok  = era.TryEnd();

            Ensure.That(ok, @"Era contested.");

            return(era);
        }
Beispiel #4
0
        /// <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());
        }