Пример #1
0
        public IEnumerator TimerComplete()
        {
            UnityEventListenerMock timerStartedMock      = new UnityEventListenerMock();
            UnityEventListenerMock timerCancelledMock    = new UnityEventListenerMock();
            UnityEventListenerMock timerCompleteMock     = new UnityEventListenerMock();
            UnityEventListenerMock timerStillRunningMock = new UnityEventListenerMock();
            UnityEventListenerMock timerNotRunningMock   = new UnityEventListenerMock();

            subject.Started.AddListener(timerStartedMock.Listen);
            subject.Cancelled.AddListener(timerCancelledMock.Listen);
            subject.Completed.AddListener(timerCompleteMock.Listen);
            subject.StillRunning.AddListener(timerStillRunningMock.Listen);
            subject.NotRunning.AddListener(timerNotRunningMock.Listen);

            subject.StartTime = 0.1f;

            Assert.IsFalse(timerStartedMock.Received);
            Assert.IsFalse(timerCancelledMock.Received);
            Assert.IsFalse(timerCompleteMock.Received);
            Assert.IsFalse(timerStillRunningMock.Received);
            Assert.IsFalse(timerNotRunningMock.Received);

            subject.Begin();

            Assert.IsTrue(timerStartedMock.Received);
            Assert.IsFalse(timerCancelledMock.Received);
            Assert.IsFalse(timerCompleteMock.Received);

            subject.EmitStatus();

            Assert.IsTrue(timerStillRunningMock.Received);
            Assert.IsFalse(timerNotRunningMock.Received);

            yield return(new WaitForSeconds(0.1f));

            Assert.IsFalse(timerCancelledMock.Received);
            Assert.IsTrue(timerCompleteMock.Received);

            timerStillRunningMock.Reset();
            timerNotRunningMock.Reset();

            subject.EmitStatus();

            Assert.IsFalse(timerStillRunningMock.Received);
            Assert.IsTrue(timerNotRunningMock.Received);
        }