Ejemplo n.º 1
0
        public void Constructor_WithData_ExpectedValues()
        {
            // Setup
            var mocks       = new MockRepository();
            var calculation = mocks.Stub <ICalculation>();

            mocks.ReplayAll();

            // Call
            using (var view = new GeneralResultSubMechanismIllustrationPointView(calculation, () => null))
            {
                // Assert
                Assert.IsInstanceOf <GeneralResultIllustrationPointView <TopLevelSubMechanismIllustrationPoint> >(view);

                Assert.AreEqual(1, view.Controls.Count);

                var splitContainer = view.Controls[0] as SplitContainer;
                Assert.IsNotNull(splitContainer);
                Control.ControlCollection splitContainerPanel1Controls = splitContainer.Panel1.Controls;
                Assert.AreEqual(1, splitContainerPanel1Controls.Count);
                Assert.IsInstanceOf <IllustrationPointsControl>(splitContainerPanel1Controls[0]);

                CollectionAssert.IsEmpty(splitContainer.Panel2.Controls);
            }

            mocks.VerifyAll();
        }
Ejemplo n.º 2
0
        public void GivenFullyConfiguredView_WhenSelectingCellInRow_ThenSelectionChangedAndPropagatedAccordingly()
        {
            // Given
            var mocks       = new MockRepository();
            var calculation = mocks.Stub <ICalculation>();

            mocks.ReplayAll();

            GeneralResult <TopLevelSubMechanismIllustrationPoint> generalResult = GetGeneralResultWithTwoTopLevelIllustrationPoints();
            var view = new GeneralResultSubMechanismIllustrationPointView(calculation, () => generalResult);

            ShowTestView(view);

            var selectionChangedCount = 0;

            view.SelectionChanged += (sender, args) => selectionChangedCount++;

            DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView");

            // When
            dataGridView.CurrentCell = dataGridView.Rows[1].Cells[0];
            EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(0, 0));

            // Then
            Assert.AreEqual(1, selectionChangedCount);

            TopLevelSubMechanismIllustrationPoint[] topLevelIllustrationPoints = generalResult.TopLevelIllustrationPoints.ToArray();
            TopLevelSubMechanismIllustrationPoint   topLevelIllustrationPoint  = topLevelIllustrationPoints.ElementAt(1);

            AssertIllustrationPointSelection(topLevelIllustrationPoint,
                                             topLevelIllustrationPoints.Select(ip => ip.ClosingSituation),
                                             view.Selection);
            mocks.VerifyAll();
        }
Ejemplo n.º 3
0
        public void Constructor_GeneralResultWithoutIllustrationPoints_DataSetOnIllustrationPointControl()
        {
            // Setup
            var mocks       = new MockRepository();
            var calculation = mocks.Stub <ICalculation>();

            mocks.ReplayAll();

            // Call
            var view = new GeneralResultSubMechanismIllustrationPointView(calculation, () => null);

            ShowTestView(view);

            // Assert
            IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(view);

            CollectionAssert.IsEmpty(illustrationPointsControl.Data);
            mocks.VerifyAll();
        }
Ejemplo n.º 4
0
        public void Constructor_GeneralResultWithIllustrationPoints_DataSetOnIllustrationPointControl()
        {
            // Setup
            var mocks       = new MockRepository();
            var calculation = mocks.Stub <ICalculation>();

            mocks.ReplayAll();

            GeneralResult <TopLevelSubMechanismIllustrationPoint> generalResult = GetGeneralResultWithTwoTopLevelIllustrationPoints();

            // Call
            var view = new GeneralResultSubMechanismIllustrationPointView(calculation, () => generalResult);

            ShowTestView(view);

            // Assert
            IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(view);

            AssertIllustrationPointControlItems(generalResult, illustrationPointsControl);
            mocks.VerifyAll();
        }
Ejemplo n.º 5
0
 private void ShowTestView(GeneralResultSubMechanismIllustrationPointView view)
 {
     testForm.Controls.Add(view);
     testForm.Show();
 }
Ejemplo n.º 6
0
 private static IllustrationPointsControl GetIllustrationPointsControl(GeneralResultSubMechanismIllustrationPointView view)
 {
     return(TypeUtils.GetField <IllustrationPointsControl>(view, "illustrationPointsControl"));
 }