public void Constructor_WithReferenceLine_DataUpdatedToCollectionOfFilledMapData()
        {
            // Setup
            var referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new[]
            {
                new Point2D(1.0, 2.0),
                new Point2D(2.0, 1.0)
            });

            var assessmentSection = new AssessmentSectionStub
            {
                ReferenceLine = referenceLine
            };

            // Call
            AssessmentSectionReferenceLineView view = ShowCalculationsView(assessmentSection);

            // Assert
            Assert.IsInstanceOf <MapDataCollection>(view.Map.Data);
            MapDataCollection mapData = view.Map.Data;

            Assert.IsNotNull(mapData);

            MapData referenceLineMapData = mapData.Collection.ElementAt(referenceLineIndex);

            MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData);
            Assert.IsTrue(referenceLineMapData.IsVisible);
        }
        private AssessmentSectionReferenceLineView ShowCalculationsView(IAssessmentSection assessmentSection)
        {
            var assessmentSectionView = new AssessmentSectionReferenceLineView(assessmentSection);

            testForm.Controls.Add(assessmentSectionView);
            testForm.Show();

            return(assessmentSectionView);
        }
        public void Constructor_AssessmentSectionWithBackgroundData_BackgroundDataSet()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();

            // Call
            AssessmentSectionReferenceLineView view = ShowCalculationsView(assessmentSection);

            // Assert
            MapDataTestHelper.AssertImageBasedMapData(assessmentSection.BackgroundData, view.Map.BackgroundMapData);
        }
Пример #4
0
        public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue()
        {
            // Setup
            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>());

            var view = new AssessmentSectionReferenceLineView(assessmentSection);

            // Call
            bool closeForData = info.CloseForData(view, assessmentSection);

            // Assert
            Assert.IsTrue(closeForData);
        }
        public void UpdateObserver_ReferenceLineUpdated_MapDataUpdated()
        {
            // Setup
            var referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new List <Point2D>
            {
                new Point2D(1.0, 2.0),
                new Point2D(2.0, 1.0)
            });

            var assessmentSection = new AssessmentSectionStub
            {
                ReferenceLine = referenceLine
            };

            AssessmentSectionReferenceLineView view = ShowCalculationsView(assessmentSection);

            IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl;

            var       mocks    = new MockRepository();
            IObserver observer = AttachReferenceLineMapDataObserver(mocks, map.Data.Collection);

            observer.Expect(obs => obs.UpdateObserver());
            mocks.ReplayAll();

            MapData referenceLineMapData = map.Data.Collection.ElementAt(referenceLineIndex);

            // Precondition
            MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData);
            Assert.IsTrue(referenceLineMapData.IsVisible);

            // Call
            referenceLine.SetGeometry(new List <Point2D>
            {
                new Point2D(2.0, 5.0),
                new Point2D(4.0, 3.0)
            });
            referenceLine.NotifyObservers();

            // Assert
            MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData);
            Assert.IsTrue(referenceLineMapData.IsVisible);
            mocks.VerifyAll();
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();

            // Call
            AssessmentSectionReferenceLineView view = ShowCalculationsView(assessmentSection);

            // Assert
            Assert.IsInstanceOf <UserControl>(view);
            Assert.IsInstanceOf <IMapView>(view);
            Assert.IsNull(view.Data);

            Assert.AreEqual(1, view.Controls.Count);
            Assert.IsInstanceOf <RiskeerMapControl>(view.Controls[0]);
            Assert.AreSame(view.Map, ((RiskeerMapControl)view.Controls[0]).MapControl);
            Assert.AreSame(assessmentSection, view.AssessmentSection);
            Assert.AreEqual(DockStyle.Fill, ((Control)view.Map).Dock);
            AssertEmptyMapData(view.Map.Data);
        }