コード例 #1
0
        public void TimeSpanComponent_Dispose()
        {
            using var t = new TestComponent(TimeSpan.FromMilliseconds(500), this.Logger);

            t.Initialize();
            t.Dispose();
            Assert.IsTrue(t.IsDisposed);

            t.Initialize();
        }
コード例 #2
0
        public void TimeSpanComponent_Usage()
        {
            using var t = new TestComponent(TimeSpan.FromMilliseconds(500), this.Logger);

            Assert.AreEqual(0, t.Count);

            Assert.IsFalse(t.IsInitialized);
            Assert.IsFalse(t.IsDisposed);

            t.Initialize();

            Assert.AreEqual(1, t.Count);
            Assert.IsTrue(t.IsInitialized);

            t.Initialize();
            Assert.AreEqual(1, t.Count);

            Thread.Sleep(1000);

            Assert.AreEqual(1, t.Count);

            t.Initialize();
            Assert.AreEqual(2, t.Count);
            Assert.IsTrue(t.IsInitialized);

            t.Initialize();
            Assert.AreEqual(2, t.Count);

            Thread.Sleep(2000);

            Assert.AreEqual(2, t.Count);

            t.Initialize();
            Assert.AreEqual(3, t.Count);
            t.Initialize();

            t.Dispose();
            Assert.IsTrue(t.IsDisposed);
        }