using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Week_11___TTTLib;

namespace Week_11___TTTTests
{
    [TestClass]
    public class UnitTest1
    {
        IGameWinnerService _gameWinnerService;
        char[,] _gameBoard;

        [TestInitialize]
        public void Initialise()
        {
            _gameWinnerService = new GameWinnerService();
            _gameBoard = new char[,]
            {
                {' ', ' ', ' ' },
                {' ', ' ', ' ' },
                {' ', ' ', ' ' }
            };
        }

        [TestMethod]
        public void TestEmptyArray()
        {
            var actual = _gameWinnerService.Validate(_gameBoard);
            Assert.AreEqual(' ', actual);
        }

        [TestMethod]
        public void TestPlayerWithAllCrossesInTopRowIsWinner()
        {
            const char expected = 'X';

            _gameBoard[0, 0] = expected;
            _gameBoard[0, 1] = expected;
            _gameBoard[0, 2] = expected;

            var actual = _gameWinnerService.Validate(_gameBoard);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void TestPlayerWithAllNaughtsInTopRowIsWinner()
        {
            const char expected = 'O';

            _gameBoard[0, 0] = expected;
            _gameBoard[0, 1] = expected;
            _gameBoard[0, 2] = expected;
            var actual = _gameWinnerService.Validate(_gameBoard);
            Assert.AreEqual(expected, actual);
        }
    }
}
