using System;
using System.Threading;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using PacManGame;

namespace PacManGameTests
{
    [TestFixture]
    public class GameTimerTest
    {

        [Test]
        public void GivenABoard3x4WithPacmanLookingUpAt1x2_When500msPass_ThenPacmanIsAt1x1()
        {
            //Arrange
            Board b = new Board(3, 4);
            ITimer gameTimer = new GameTimer(500);
            GameController gameController = new GameController(b, gameTimer);
            gameTimer.Start();

            //Act
            Thread.Sleep(TimeSpan.FromMilliseconds(600));

            // Assert
            b.PacMan.Position.Should().Be(new Position(1, 1));
        }


        [Test]
        public void GivenABoardTickableAndAGameController_WhenTimerElapsed_ThenATickIsCalled()
        {
            //Arrange
            ITickable boardMock = Mock.Of<ITickable>();
            FakeTimer timer = new FakeTimer();
            GameController gameController = new GameController(boardMock, timer);

            //Act
            timer.OnElapsed();

            //Assert
            Mock.Get(boardMock).Verify(b => b.Tick(), Times.Once);
        }
    }



    public class FakeTimer : ITimer
    {
        public event EventHandler Elapsed;
        public void Start()
        {
            throw new NotImplementedException();
        }

        public void OnElapsed()
        {
            if (Elapsed != null)
            {
                Elapsed(this, new EventArgs());
            }
        }
    }
}
using System;
using System.Threading;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using PacManGame;

namespace PacManGameTests
{
    [TestFixture]
    public class GameTimerTest
    {

        [Test]
        public void GivenABoard3x4WithPacmanLookingUpAt1x2_When500msPass_ThenPacmanIsAt1x1()
        {
            //Arrange
            Board b = new Board(3, 4);
            ITimer gameTimer = new GameTimer(500);
            GameController gameController = new GameController(b, gameTimer);
            gameTimer.Start();

            //Act
            Thread.Sleep(TimeSpan.FromMilliseconds(600));

            // Assert
            b.PacMan.Position.Should().Be(new Position(1, 1));
        }


        [Test]
        public void GivenABoardTickableAndAGameController_WhenTimerElapsed_ThenATickIsCalled()
        {
            //Arrange
            ITickable boardMock = Mock.Of<ITickable>();
            ITimer timerMock = Mock.Of<ITimer>();
            GameController gameController = new GameController(boardMock, timerMock);

            //Act
            Mock.Get(timerMock).Raise(t => t.Elapsed += null, new EventArgs());

            //Assert
            Mock.Get(boardMock).Verify(b => b.Tick(), Times.Once);
        }
    }
}
Use a stub of ITimer instead of an actual implementation
Use a stub of ITimer instead of an actual implementation
