Beispiel #1
0
        public void Init()
        {
            view = A.Fake <FPSCounterComponent.IFPSCounterComponentView>();
            A.CallTo(() => view.getSizeFromString(A <string> .Ignored)).Returns(textSize);

            graphicConf       = new GraphicConfiguration();
            graphicConf.Width = 100;

            presenter = new FPSCounterComponent(view, graphicConf);
            presenter.Update(new GameTime()); // update first time as this is counted as a second, so the fps are now 1.
        }
Beispiel #2
0
        private void CalculateFrameRateTest(int fps)
        {
            // we need to actually round cause a long have no decimal places
            long ticksPerFrame = Convert.ToInt64(Math.Round(TimeSpan.TicksPerSecond / (double)fps));

            GameTime gameTime = new GameTime();

            gameTime.ElapsedGameTime = TimeSpan.FromTicks(ticksPerFrame);

            for (int i = 0; i < fps; i++)
            {
                presenter.Update(gameTime);
            }

            Assert.AreEqual(fps, presenter.CurrentFrameRate);
        }