예제 #1
0
        public async Task Test___Method_Reset___Status_Completed()
        {
            var elapsed = new AnyVariable <long>()
            {
                Value = 0
            };

            var testee = new StopwatchActivity()
            {
                Activity = new DelayActivity()
                {
                    Duration = new AnyVariable <int>()
                    {
                        Value = 1000
                    }
                },
                Elapsed = elapsed
            };

            await testee.Start();

            Assert.AreEqual(ActivityStatus.Completed, testee.Status);
            Assert.AreNotEqual(0, elapsed.GetValueAsObject());

            testee.Reset();

            Assert.AreEqual(ActivityStatus.Created, testee.Status);
        }
예제 #2
0
        public async Task Test___Method_Stop___Status_Executing()
        {
            var elapsed = new AnyVariable <long>()
            {
                Value = 0
            };

            var testee = new StopwatchActivity()
            {
                Activity = new DelayActivity()
                {
                    Duration = new AnyVariable <int>()
                    {
                        Value = 1000
                    }
                },
                Elapsed = elapsed
            };

            var task = testee.Start();

            testee.Stop();

            await task;

            Assert.AreEqual(ActivityStatus.Stopped, testee.Status);
            Assert.AreNotEqual(0, elapsed.GetValueAsObject());
        }
예제 #3
0
        public async Task Test___Method_Start()
        {
            var elapsed    = new AnyVariable <long>();
            var lockObject = new LockVariable();

            var testee = new StopwatchActivity()
            {
                Elapsed  = elapsed,
                Activity = new ParallelActivity()
                {
                    Activities = new List <IActivity>()
                    {
                        new LockActivity()
                        {
                            LockObject = lockObject,
                            Activity   = new DelayActivity()
                            {
                                Duration = new AnyVariable <int>(1000)
                            }
                        },
                        new LockActivity()
                        {
                            LockObject = lockObject,
                            Activity   = new DelayActivity()
                            {
                                Duration = new AnyVariable <int>(1000)
                            }
                        }
                    }
                }
            };

            await testee.Start();

            Assert.AreEqual(ActivityStatus.Completed, testee.Status);
            Assert.IsTrue(2000 <= elapsed.GetValue());
        }