コード例 #1
0
        public void GetNextCellValue_ShouldReturnOne_WhenInvokedForTheFirstTime()
        {
            var valueSequence = new BasicCellValueSequence();

            var actualFirstValue = valueSequence.GetNextCellValue();

            Assert.That(actualFirstValue, Is.EqualTo(1));
        }
コード例 #2
0
        public void GetNextCellValue_ShouldIncrementValuesByOne()
        {
            var valueSequence = new BasicCellValueSequence();

            for (int i = 0; i < 1000; i++)
            {
                valueSequence.GetNextCellValue();
            }

            var value     = valueSequence.GetNextCellValue();
            var nextValue = valueSequence.GetNextCellValue();

            Assert.That(value + 1, Is.EqualTo(nextValue));
        }
コード例 #3
0
        public static void Main()
        {
            var ui = new BasicUserInterface(Console.WriteLine, Console.ReadLine);
            var inputMatrixSize = ui.AskForInput("Enter matrix size: ");

            int parsedMatrixSize;
            var isSuccessfullyParsed = int.TryParse(inputMatrixSize, out parsedMatrixSize);

            if (isSuccessfullyParsed)
            {
                var theMatrix = new BasicMatrix(parsedMatrixSize, InstantiatingMethods.CreateMatrixCell);

                var directionSequence = new BasicPathDirectionSequence(InstantiatingMethods.CreateDirection);
                var valuesGenerator   = new BasicCellValueSequence();
                var startPosition     = new Position(0, 0);

                theMatrix.Populate(startPosition, directionSequence, valuesGenerator);
                ui.PostMessage(theMatrix.ToString());
            }
            else
            {
                ui.PostMessage("Invalid matrix size input.");
            }
        }