コード例 #1
0
        public void ShouldThrowsArgumentExceptionWhenBoardIsOutOfRange()
        {
            //Given
            Board      board   = new Board(3, 3, new ConwaysRule());
            IGoLObject blinker = GoLObjectFactory.Create(GoLPatterns.Blinker);
            //When
            var ex = Assert.Throws <ArgumentException>(() => blinker.Fill(board, 1, 2));

            //Then
            ex.Message.ShouldBe("3 or 2 is not valid range. Board size is 3, 3");
        }
コード例 #2
0
        public void ShouldInitBlinkerObject()
        {
            //Given
            Board      board   = new Board(5, 5, new ConwaysRule());
            IGoLObject blinker = GoLObjectFactory.Create(GoLPatterns.Blinker);
            GoLHelper  helper  = new GoLHelper(5, 5);

            //When
            blinker.Fill(board, 1, 2);
            //Then
            board.Table.ShouldBe(helper.CreateBlinkerFirstState(1, 2));
        }
コード例 #3
0
        public void ShouldInvokeBoardGeneration()
        {
            //Given
            Board      board   = new Board(5, 5, new ConwaysRule());
            IGoLObject blinker = GoLObjectFactory.Create(GoLPatterns.Blinker);
            GoLHelper  helper  = new GoLHelper(5, 5);

            //When
            blinker.Fill(board, 1, 2);
            board.NextGeneration();
            //Then
            board.Table.ShouldBe(helper.CreateBlinkerSecondState(2, 1));
        }
コード例 #4
0
        public void BlockShouldBeTheSameBlock()
        {
            //Given
            Board      board  = new Board(4, 4, new ConwaysRule());
            IGoLObject block  = GoLObjectFactory.Create(GoLPatterns.Block);
            GoLHelper  helper = new GoLHelper(4, 4);

            //When
            block.Fill(board, 1, 1);
            board.NextGeneration();
            board.NextGeneration();
            //Then
            board.Table.ShouldBe(helper.CreateBlock(1, 1));
        }
コード例 #5
0
        public void BlinkerAfter2GenerationShouldReturnToInitState()
        {
            //Given
            Board      board   = new Board(5, 5, new ConwaysRule());
            IGoLObject blinker = GoLObjectFactory.Create(GoLPatterns.Blinker);
            GoLHelper  helper  = new GoLHelper(5, 5);

            //When
            blinker.Fill(board, 1, 2);
            board.NextGeneration();
            board.NextGeneration();
            //Then
            board.Table.ShouldBe(helper.CreateBlinkerFirstState(1, 2));
        }