コード例 #1
0
        public void TestEvents()
        {
            DummyController controller = new DummyController();
            var             clock      = controller.Clock;

            Assert.IsNotNull(clock);

            Assert.IsFalse(clock.IsRunning);
            controller.MountAudio(new DummyAudio());
            Assert.IsTrue(clock.IsRunning);
            controller.MountAudio(null);
            Assert.IsFalse(clock.IsRunning);

            Assert.IsFalse(clock.IsPlaying);
            controller.Play();
            Assert.AreEqual(0f, clock.CurrentTime, Delta);
            Assert.IsTrue(clock.IsPlaying);
            controller.Play(2000f);
            Assert.AreEqual(0f, clock.CurrentTime, Delta);

            controller.Stop();
            Assert.IsFalse(clock.IsPlaying);
            Assert.IsFalse(clock.IsPaused);
            Assert.IsTrue(clock.IsStopped);

            controller.Play(2000f);
            Assert.AreEqual(-2000f, clock.CurrentTime, Delta);
            Assert.IsTrue(clock.IsPlaying);
            Assert.IsFalse(clock.IsPaused);
            Assert.IsFalse(clock.IsStopped);

            controller.Pause();
            Assert.AreEqual(-2000f, clock.CurrentTime, Delta);
            Assert.IsFalse(clock.IsPlaying);
            Assert.IsTrue(clock.IsPaused);
            Assert.IsFalse(clock.IsStopped);

            controller.Stop();
            Assert.AreEqual(0f, clock.CurrentTime, Delta);

            Assert.AreEqual(1f, clock.Rate);
            controller.SetTempo(2f);
            Assert.AreEqual(2f, clock.Rate, Delta);

            Assert.AreEqual(0f, clock.CurrentTime, Delta);
            controller.Seek(5000f);
            Assert.AreEqual(10000f, clock.CurrentTime, Delta);
            controller.SetTempo(1f);
            Assert.AreEqual(5000, clock.CurrentTime, Delta);

            clock.Offset = 1000f;
            Assert.AreEqual(6000f, clock.CurrentTime, Delta);
        }