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

            era.Dispose();

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

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

            return(era);
        }
示例#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());
        }