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); }
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()); }
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()); }