예제 #1
0
        public void Test_TrySetFalse_already_falsy()
        {
            var boolean = new AtomicBoolean();

            boolean.TrySetFalse().Should().BeFalse();
            ((bool)boolean).Should().BeFalse();
        }
예제 #2
0
        public void Test_TrySetFalse_truly()
        {
            var boolean = new AtomicBoolean();

            boolean.TrySetTrue();

            boolean.TrySetFalse().Should().BeTrue();
            ((bool)boolean).Should().BeFalse();
        }
예제 #3
0
        /// <inheritdoc />
        public void Stop()
        {
            lock (startStopSync)
            {
                if (isRunning.TrySetFalse())
                {
                    log.Info("Stopped. Unregistering..");

                    stopCancellationToken.Cancel();
                    checkNodeSignal.Set();
                    beaconTask.GetAwaiter().GetResult();
                    stopCancellationToken.Dispose();
                    if (!DeleteNodeAsync().GetAwaiter().GetResult())
                    {
                        Task.Run(DeleteNodeTask);
                    }
                }
            }
        }
예제 #4
0
        public void TrySetFalse_should_return_true_if_value_was_true()
        {
            boolean.Value = true;

            boolean.TrySetFalse().Should().BeTrue();
        }