Exemplo n.º 1
0
        public async Task UnInitSRVTest()
        {
            this.counter = 0;
            SelfRefreshingVar <int> srv = new SelfRefreshingVar <int>(TimeSpan.FromSeconds(10), this.AtomicIncrement, this.failTest);

            Assert.AreEqual(0, srv.GetValue());
            await srv.Initialize();

            Assert.AreEqual(1, srv.GetValue());
        }
Exemplo n.º 2
0
        public void IncrementSRVTest()
        {
            this.counter = 0;
            SelfRefreshingVar <int> srv = new SelfRefreshingVar <int>(0, TimeSpan.FromSeconds(3), this.AtomicIncrement, this.failTest);

            // sleep for 10 seconds, and check if value is 3
            Thread.Sleep(10 * 1000);
            Assert.AreEqual(3, srv.GetValue());
        }
Exemplo n.º 3
0
        public void DisposeSRVTest()
        {
            this.counter = 0;
            SelfRefreshingVar <int> srv = new SelfRefreshingVar <int>(0, TimeSpan.FromSeconds(2), this.AtomicIncrement, this.failTest);

            // sleep for 3 seconds
            Thread.Sleep(3 * 1000);

            // Dispose
            srv.Dispose();

            // sleep for another 2 seconds
            Thread.Sleep(2 * 1000);
            Assert.AreEqual(1, srv.GetValue());
        }