コード例 #1
0
        public void ExpectGetPrintFrameOfPrintDecoratorNotToBeEmptyString()
        {
            var matrix = new MatrixFactory().CreateMatrix(MatrixTypes.BIG);

            var player = new Player();

            var printer = new PrinterLightMode();
            var standartPrinter = new StandardPrinter();
            printer.SetPrinter(standartPrinter);

            var result = printer.GetPrintFrame(matrix, player);

            Assert.AreNotEqual(result.Length, 0);
        }
コード例 #2
0
        public void ExpectGetPrintFrameToReturntNotEmptyString()
        {
            var director = new MatrixDirector();
            var builder = new SmallMatrixBuilder();
            director.Construct(builder);
            var matrix = builder.GetMatrix();

            var player = new Player();

            var printer = new StandardPrinter();

            var result = printer.GetPrintFrame(matrix, player);

            Assert.AreNotEqual(result.Length, 0);
        }
コード例 #3
0
        public void ScoresHandlerRecordsListIsUpdatedWhenAddingRecords(int count)
        {
            ScoresHandler scoresHandler = new ScoresHandler();

            int expectedListLength = scoresHandler.Reccords.Count + count;

            for (int i = 0; i < count; i++)
            {
                Player player = new Player(string.Format("Petkan{0}", i), i);
                scoresHandler.AddReccord(player);
            }

            int newListLength = scoresHandler.Reccords.Count;

            Assert.AreEqual(expectedListLength, newListLength, "List of Records are not updated!");
        }
コード例 #4
0
        public void DefaultSortMethodSortsProperFirstByScoreSecondByName()
        {
            DefaultSort sorter = new DefaultSort();

            IPlayer first = new Player("Ivan", 2);
            IPlayer second = new Player("Angel", 1);
            IPlayer third = new Player("Angus", 1);

            IList<IPlayer> inputPlayers = new List<IPlayer> { first, third, second };

            IList<IPlayer> expectedPlayers = new List<IPlayer> { first, second, third };

            IList<IPlayer> actualPlayers = sorter.Sort(inputPlayers);

            Assert.IsTrue(expectedPlayers.SequenceEqual(actualPlayers), "The expected and the result lists of sorted Players are NOT equal!");
        }
コード例 #5
0
        public void ExpectLoadFromFileToLoadCorrectList()
        {
            var fileName = "testFile.txt";
            var scoreHandler = new ScoresHandler();
            var playerA = new Player("TestPlayerA", 1);
            var playerB = new Player("TestPlayerB", 2);
            scoreHandler.AddReccord(playerA);
            scoreHandler.AddReccord(playerB);

            scoreHandler.SaveToFile(fileName);

            scoreHandler.LoadFromFile(fileName);

            Assert.AreEqual(2, scoreHandler.Reccords.Count, "The loaded scores are {0}, which is incorect value", scoreHandler.Reccords.Count);

            File.Delete(fileName);
        }
コード例 #6
0
 /// <summary>
 /// Sets the obligatory parameters needed to process the commands in the constuctor
 /// </summary>
 /// <param name="matrix">import the matrix</param>
 /// <param name="player">set the current player</param>
 /// <param name="printer">import the printer</param>
 public Command(Matrix matrix, Player player, Printer printer)
 {
     this.Matrix = matrix;
     this.Player = player;
     this.Printer = printer;
 }
コード例 #7
0
        public void PlayerClassEmptyConstructorMustConstructInstance()
        {
            Player player = new Player();

            Assert.IsInstanceOf(typeof(Player), player, "Memento instance doesn't exist");
        }
コード例 #8
0
 /// <summary>
 /// Constructor for the invalid command.
 /// </summary>
 /// <param name="matrix">Current game matrix</param>
 /// <param name="player">Current game player.</param>
 /// <param name="printer">Current game printer.</param>
 public InvalidCommand(Matrix matrix, Player player, Printer printer)
     : base(matrix, player, printer)
 {
 }
コード例 #9
0
 /// <summary>
 /// Command for exiting the game environment.
 /// </summary>
 /// <param name="matrix">Object with the field and field logic</param>
 /// <param name="player">Current player.</param>
 /// <param name="printer">Printer for the game used currently</param>
 public ExitCommand(Matrix matrix, Player player, Printer printer)
     : base(matrix, player, printer)
 {
 }
コード例 #10
0
        public void ExpectPrintMatrixNotToThrow()
        {
            var matrix = new MatrixFactory().CreateMatrix(MatrixTypes.BIG);
            var player = new Player();

            var printer = new StandardPrinter();

            Assert.DoesNotThrow(() => printer.PrintMatrix(matrix, player));
        }