public void Exchange_MustReturnTrue()
        {
            var once = new ConcurrentOnce();
            var ok   = once.Exchange();

            Assert.IsTrue(ok);
        }
Esempio n. 2
0
 protected BindBoxBase(IConfigurationChangeNotifyable changeNotifyable, BindSettings bindSettings, ConfigBindMode mode)
 {
     ChangeNotifyable = changeNotifyable ?? throw new ArgumentNullException(nameof(changeNotifyable));
     BindSettings     = bindSettings ?? throw new ArgumentNullException(nameof(bindSettings));
     Mode             = mode;
     once             = new ConcurrentOnce();
 }
Esempio n. 3
0
 public BindBox(IConfigurationChangeNotifyable changeNotifyable, BindSettings bindSettings, ConfigBindMode mode, Action <Action> updater)
 {
     ChangeNotifyable = changeNotifyable ?? throw new ArgumentNullException(nameof(changeNotifyable));
     BindSettings     = bindSettings ?? throw new ArgumentNullException(nameof(bindSettings));
     Mode             = mode;
     Updater          = updater ?? throw new ArgumentNullException(nameof(updater));
     once             = new ConcurrentOnce();
 }
        public async Task RunWhenConcurrent_PrevMustFail()
        {
            var once = new ConcurrentOnce();
            var ok1  = once.WaitAsync(TimeSpan.FromSeconds(1));
            var ok2  = await once.WaitAsync(TimeSpan.Zero);

            Assert.IsTrue(ok2);
            Assert.IsFalse(await ok1);
        }
        public async Task RunOnce_MustReturnTrue()
        {
            var once = new ConcurrentOnce();
            var ok   = await once.WaitAsync(TimeSpan.Zero);

            Assert.IsTrue(ok);

            once.ToString();
        }
        public async Task RunWhenExchanged_MustReturnFail()
        {
            var once = new ConcurrentOnce();
            var res1 = once.WaitAsync(TimeSpan.FromSeconds(3));
            var res2 = once.Exchange();

            Assert.IsTrue(res2);
            Assert.IsFalse(await res1);
        }
        public async Task RunAfter_TokenMustChanged()
        {
            var once = new ConcurrentOnce();
            var tk1  = once.Token;
            await once.WaitAsync(TimeSpan.Zero);

            var tk2 = once.Token;

            Assert.AreNotEqual(tk1, tk2);
        }