public void SchedulerClearFinishedEventsTest()
    {
        Assert.That(scheduler.Events.Count, Is.EqualTo(0));

        ScheduledEvent evt1 = new ScheduledEvent(
            "test",
            callback,
            2.0f,
            true,
            1);
        ScheduledEvent evt2 = new ScheduledEvent(
            "test",
            callback,
            3.0f,
            true,
            1);

        scheduler.RegisterEvent(evt1);
        scheduler.RegisterEvent(evt2);
        scheduler.Update(0); // updates the event list

        evt2.Stop();
        Assert.That(scheduler.IsRegistered(evt2), Is.True);
        scheduler.Update(0); // updates the event list
        Assert.That(scheduler.IsRegistered(evt2), Is.False);

        evt1.Stop();
        Assert.That(scheduler.IsRegistered(evt1), Is.True);
        scheduler.Update(0); // updates the event list
        Assert.That(scheduler.IsRegistered(evt1), Is.False);
    }
예제 #2
0
    public void StopEventRunTest()
    {
        ScheduledEvent evt = new ScheduledEvent(
            "test",
            callback,
            3.0f,
            true,
            1);

        // doesn't run until the cooldown is reached
        Reset();
        evt.Update(5.0f);
        Assert.That(evt.LastShot, Is.False);
        Assert.That(evt.Finished, Is.False);
        Assert.That(didRun, Is.True);

        evt.Stop();

        // and now it should not run
        Assert.That(evt.LastShot, Is.False);
        Assert.That(evt.Finished, Is.True);
        Reset();
        evt.Update(5.0f);
        Assert.That(didRun, Is.False);
    }