Esempio n. 1
0
        public void SetNeighboursToAllCellsShouldSetEightNeighboursToMiddleCells()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService       = new GridService(grid);
            var cellActionService = new CellActionService(gridService);
            var twoDGridService   = new TwoDGridActionService(grid, cellActionService);

            // Act
            twoDGridService.SetNeighboursToAllCells();

            // Assert
            grid[1][2]
            .Neighbours
            .Count
            .Should()
            .Be(8);

            grid[2][2]
            .Neighbours
            .Count
            .Should()
            .Be(8);
        }
        public static void Run()
        {
            MockGrid g = new MockGrid();
            BarycentricIntegralPointMapper m = new BarycentricIntegralPointMapper(g);
            Point camera, beamer;

            // Top Left
            camera = new Point(265, 70);
            beamer = m.FromPresentation(camera);
            Console.WriteLine("{0} -> {1}", camera, beamer);

            // Bottom Left
            camera = new Point(265, 313);
            beamer = m.FromPresentation(camera);
            Console.WriteLine("{0} -> {1}", camera, beamer);

            // Top Right
            camera = new Point(522, 126);
            beamer = m.FromPresentation(camera);
            Console.WriteLine("{0} -> {1}", camera, beamer);

            // Bottom Right
            camera = new Point(533, 333);
            beamer = m.FromPresentation(camera);
            Console.WriteLine("{0} -> {1}", camera, beamer);

            // Center
            camera = new Point(409, 480 - 270);
            beamer = m.FromPresentation(camera);
            Console.WriteLine("{0} -> {1}", camera, beamer);
        }
Esempio n. 3
0
        public void CountOfTargetBeingGreenWithSetTargetSellAfterGenerateShouldReturnRigthCount()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService       = new GridService(grid);
            var cellActionService = new CellActionService(gridService);
            var twoDGridService   = new TwoDGridActionService(grid, cellActionService);

            var targetY            = 2;
            var targetX            = 2;
            var numberOfGeneration = 15;

            twoDGridService.SetNeighboursToAllCells();
            twoDGridService.SetTargetCell(targetY, targetX);

            // Act
            twoDGridService.Generate(numberOfGeneration);

            // Assert
            twoDGridService
            .GetCountOfTargetBeingGreen()
            .Should()
            .Be(14);
        }
Esempio n. 4
0
        private void LoadMockRecord()
        {
            //그리드속성
            MockGrid.AutoGenerateColumns = false;
            MockGrid.AllowUserToAddRows  = false;
            MockGrid.MultiSelect         = true;
            MockGrid.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
            MockGrid.RowHeadersWidth     = 15;
            MockGrid.ColumnHeadersHeight = 20;
            MockGrid.ColumnHeadersDefaultCellStyle.Font = new Font("Segoe UI", 9.5F);
            MockGrid.RowsDefaultCellStyle.Font          = new Font("Segoe UI", 9.5F);
            UtilityClass.AddNewColumnToDataGridView(MockGrid, "학년", "grade", true, 60);
            UtilityClass.AddNewColumnToDataGridView(MockGrid, "국어", "korean", true, 60);
            UtilityClass.AddNewColumnToDataGridView(MockGrid, "영어", "english", true, 60);
            UtilityClass.AddNewColumnToDataGridView(MockGrid, "수학", "math", true, 60);
            UtilityClass.AddNewColumnToDataGridView(MockGrid, "사회/과학1", "side_choice1", true, 100);
            UtilityClass.AddNewColumnToDataGridView(MockGrid, "사회/과학2", "side_choice2", true, 100);
            UtilityClass.AddNewColumnToDataGridView(MockGrid, "제2외국어", "more_foreign", true, 90);
            UtilityClass.AddNewColumnToDataGridView(MockGrid, "평균", "total_avg", true, 60);
            UtilityClass.AddNewColumnToDataGridView(MockGrid, "등급컷", "cut", true, 70);

            SchoolRecordInfoDAC DAC = new SchoolRecordInfoDAC();
            DataSet             ds  = DAC.GetMockRecordAvg(lblStudentID.Text);

            MockGrid.DataSource = ds.Tables[0];
            MockGrid.ClearSelection();
            DAC.Dispose();
        }
Esempio n. 5
0
        public void GetHeightShouldReturnGridLength()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService = new GridService(grid);

            // Act
            var result = gridService.GetHeight();

            // Assert
            result
            .Should()
            .Be(4);
        }
Esempio n. 6
0
        public void GetWidthShouldThrowIndexOutOfRangeExeptionWithNegativeParameter()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService = new GridService(grid);
            var rowIndex    = -1;

            // Act
            Action action = () => gridService.GetWidth(rowIndex);

            // Assert
            action
            .Should()
            .Throw <IndexOutOfRangeException>();
        }
Esempio n. 7
0
        public void GetWidthShouldReturnGridsRowLength()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService = new GridService(grid);
            var rowIndex    = 1;

            // Act
            var result = gridService.GetWidth(rowIndex);

            // Assert
            result
            .Should()
            .Be(4);
        }
Esempio n. 8
0
        public void GetCountOfTargetBeingGreenReturnsZeroWithNotSetTargetCell()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService       = new GridService(grid);
            var cellActionService = new CellActionService(gridService);
            var twoDGridService   = new TwoDGridActionService(grid, cellActionService);

            // Act

            // Assert
            twoDGridService
            .GetCountOfTargetBeingGreen()
            .Should()
            .Be(0);
        }
Esempio n. 9
0
        public void FindUpLeftNeighbourShouldReturnRigthCell()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService = new GridService(grid);
            var testedCellY = 1;
            var testedCellX = 1;

            // Act
            var result = gridService.FindUpLeftNeighbour(testedCellY, testedCellX);

            // Assert
            result
            .Should()
            .BeEquivalentTo <Cell>(grid[0][0]);
        }
Esempio n. 10
0
        public void FindUpNeighbourShouldThrowIndexOutOfRangeException()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService = new GridService(grid);
            var testedCellY = 0;
            var testedCellX = 1;

            // Act
            Action action = () => gridService.FindUpNeighbour(testedCellY, testedCellX);

            // Assert
            action
            .Should()
            .Throw <IndexOutOfRangeException>();
        }
        public void AddNeighboursShouldSetEightNeighboursToMiddleCell()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService       = new GridService(grid);
            var cellActionService = new CellActionService(gridService);

            // Act
            cellActionService.AddNeighbours(grid[1][2]);

            // Assert
            grid[1][2]
            .Neighbours
            .Count
            .Should()
            .Be(8);
        }
        public void AddNeighboursShouldSetFiveNeighboursToSideCell()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService       = new GridService(grid);
            var cellActionService = new CellActionService(gridService);

            // Act
            cellActionService.AddNeighbours(grid[0][1]);

            // Assert
            grid[0][1]
            .Neighbours
            .Count
            .Should()
            .Be(5);
        }
        public void AddNeighboursShouldSetThreeNeighboursToCornerCell()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService       = new GridService(grid);
            var cellActionService = new CellActionService(gridService);

            // Act
            cellActionService.AddNeighbours(grid[0][0]);

            // Assert
            grid[0][0]
            .Neighbours
            .Count
            .Should()
            .Be(3);
        }
Esempio n. 14
0
        public void GenerateWithoutSetTargetSellShouldThrowNullReferenceException()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService       = new GridService(grid);
            var cellActionService = new CellActionService(gridService);
            var twoDGridService   = new TwoDGridActionService(grid, cellActionService);

            var numberOfGeneration = 15;

            // Act
            Action action = () => twoDGridService.Generate(numberOfGeneration);

            // Assert
            action
            .Should()
            .Throw <NullReferenceException>();
        }
        public void EvenChangeStateShouldSetTheCellCorrectly()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService       = new GridService(grid);
            var cellActionService = new CellActionService(gridService);
            var twoDGridService   = new TwoDGridActionService(grid, cellActionService);

            twoDGridService.SetNeighboursToAllCells();

            // Act
            cellActionService.EvenChangeState(grid[2][2]);

            // Assert
            grid[2][2]
            .OddColourState
            .Should()
            .Be(0);
        }
Esempio n. 16
0
        public void GetCountOfTargetBeingGreenReturnsZeroWithSetTargetCellEqualToRedColour()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService       = new GridService(grid);
            var cellActionService = new CellActionService(gridService);
            var twoDGridService   = new TwoDGridActionService(grid, cellActionService);

            var targetY = 0;
            var targetX = 1;

            // Act
            twoDGridService.SetTargetCell(targetY, targetX);

            // Assert
            twoDGridService
            .GetCountOfTargetBeingGreen()
            .Should()
            .Be(0);
        }
Esempio n. 17
0
        public void SetNeighboursToAllCellsShouldSetThreeNeighboursToCornerCells()
        {
            // Arrange
            var grid = MockGrid.Context();

            var gridService       = new GridService(grid);
            var cellActionService = new CellActionService(gridService);
            var twoDGridService   = new TwoDGridActionService(grid, cellActionService);

            // Act
            twoDGridService.SetNeighboursToAllCells();

            // Assert
            grid[0][0]
            .Neighbours
            .Count
            .Should()
            .Be(3);

            grid[3][3]
            .Neighbours
            .Count
            .Should()
            .Be(3);

            grid[3][0]
            .Neighbours
            .Count
            .Should()
            .Be(3);

            grid[0][3]
            .Neighbours
            .Count
            .Should()
            .Be(3);
        }