public void VerifyUpdates_CalculationWithoutOutputs_ReturnsTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            var mainWindow = mocks.Stub <IMainWindow>();
            var gui        = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.ReplayAll();

            plugin.Gui = gui;

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(new MacroStabilityInwardsCalculationScenario());

            var surfaceLines = new MacroStabilityInwardsSurfaceLineCollection();
            var context      = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            // Call
            bool updatesVerified = updateInfo.VerifyUpdates(context);

            // Assert
            Assert.IsTrue(updatesVerified);
            mocks.VerifyAll();
        }
        public void Create_WithSurfaceLines_ReturnFailureMechanismEntityWithSurfaceLineEntities()
        {
            // Setup
            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            MacroStabilityInwardsSurfaceLineCollection surfaceLines = failureMechanism.SurfaceLines;

            surfaceLines.AddRange(new[]
            {
                CreateSurfaceLine(new Random(31))
            }, "path");

            var registry = new PersistenceRegistry();

            // Call
            FailureMechanismEntity entity = failureMechanism.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(surfaceLines.Count, entity.SurfaceLineEntities.Count);
            for (var i = 0; i < surfaceLines.Count; i++)
            {
                AssertSurfaceLine(surfaceLines[i], entity.SurfaceLineEntities.ElementAt(i));
            }

            string surfaceLineCollectionSourcePath = entity.MacroStabilityInwardsFailureMechanismMetaEntities
                                                     .Single()
                                                     .SurfaceLineCollectionSourcePath;

            TestHelper.AssertAreEqualButNotSame(surfaceLines.SourcePath, surfaceLineCollectionSourcePath);
        }
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var surfaceLine1      = new MacroStabilityInwardsSurfaceLine("Line A");
            var surfaceLine2      = new MacroStabilityInwardsSurfaceLine("Line B");

            var surfaceLines = new MacroStabilityInwardsSurfaceLineCollection();

            surfaceLines.AddRange(new[]
            {
                surfaceLine1,
                surfaceLine2
            }, "path");

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            var surfaceLinesContext = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            mocks.ReplayAll();

            // Call
            object[] objects = info.ChildNodeObjects(surfaceLinesContext);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                surfaceLine1,
                surfaceLine2
            }, objects);
        }
        public void CurrentPath_SurfaceLineCollectionHasPathSet_ReturnsExpectedPath()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            const string expectedFilePath = "some/path";
            var          surfaceLines     = new MacroStabilityInwardsSurfaceLineCollection();

            surfaceLines.AddRange(new[]
            {
                new MacroStabilityInwardsSurfaceLine(string.Empty)
            }, expectedFilePath);

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            var context = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            // Call
            string currentPath = updateInfo.CurrentPath(context);

            // Assert
            Assert.AreEqual(expectedFilePath, currentPath);
            mocks.VerifyAll();
        }
        public void ForeColor_CollectionWithSurfaceLines_ReturnsControlText()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var surfaceLine1      = new MacroStabilityInwardsSurfaceLine("Line A");
            var surfaceLine2      = new MacroStabilityInwardsSurfaceLine("Line B");

            var surfaceLines = new MacroStabilityInwardsSurfaceLineCollection();

            surfaceLines.AddRange(new[]
            {
                surfaceLine1,
                surfaceLine2
            }, "path");

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            var surfaceLinesContext = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            mocks.ReplayAll();

            // Call
            Color foreColor = info.ForeColor(surfaceLinesContext);

            // Assert
            Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), foreColor);
        }
        public void UpdateSurfaceLinesWithImportedData_WithCurrentCollectionNotEmptyAndImportedDataHasPartialOverlap_UpdatesTargetCollection()
        {
            // Setup
            const string updatedSurfaceLineName = "Name A";
            const string removedSurfaceLineName = "Name B";
            const string addedSurfaceLineName   = "Name C";

            var surfaceLineOne = new MacroStabilityInwardsSurfaceLine(updatedSurfaceLineName);
            var surfaceLineTwo = new MacroStabilityInwardsSurfaceLine(removedSurfaceLineName);

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            MacroStabilityInwardsSurfaceLineCollection surfaceLineCollection = failureMechanism.SurfaceLines;

            surfaceLineCollection.AddRange(new[]
            {
                surfaceLineOne,
                surfaceLineTwo
            }, sourceFilePath);

            MacroStabilityInwardsSurfaceLine readSurfaceLineOne = DeepCloneAndModifyPoints(surfaceLineOne);
            var readSurfaceLineTwo = new MacroStabilityInwardsSurfaceLine(addedSurfaceLineName);

            MacroStabilityInwardsSurfaceLine[] readSurfaceLines =
            {
                readSurfaceLineOne,
                readSurfaceLineTwo
            };

            var strategy = new MacroStabilityInwardsSurfaceLineUpdateDataStrategy(failureMechanism);

            // Call
            IEnumerable <IObservable> affectedObjects = strategy.UpdateSurfaceLinesWithImportedData(readSurfaceLines,
                                                                                                    sourceFilePath);

            // Assert
            MacroStabilityInwardsSurfaceLine[] expectedSurfaceLineCollection =
            {
                surfaceLineOne,
                readSurfaceLineTwo
            };
            CollectionAssert.AreEqual(expectedSurfaceLineCollection, surfaceLineCollection);

            MacroStabilityInwardsSurfaceLine updatedSurfaceLine = surfaceLineCollection[0];

            Assert.AreSame(surfaceLineOne, updatedSurfaceLine);
            Assert.AreEqual(readSurfaceLineOne, updatedSurfaceLine);

            MacroStabilityInwardsSurfaceLine addedSurfaceLine = surfaceLineCollection[1];

            Assert.AreSame(readSurfaceLineTwo, addedSurfaceLine);
            Assert.AreEqual(readSurfaceLineTwo, addedSurfaceLine);

            CollectionAssert.AreEquivalent(new IObservable[]
            {
                readSurfaceLineOne,
                surfaceLineCollection
            }, affectedObjects);
        }
        public void VerifyUpdates_CalculationWithOutputs_AlwaysReturnsExpectedInquiryMessage(bool isActionConfirmed)
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            var mainWindow = mocks.Stub <IMainWindow>();
            var gui        = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.ReplayAll();

            plugin.Gui = gui;

            var failureMechanism      = new MacroStabilityInwardsFailureMechanism();
            var calculationWithOutput = new MacroStabilityInwardsCalculationScenario
            {
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            };

            failureMechanism.CalculationsGroup.Children.Add(calculationWithOutput);

            var surfaceLines = new MacroStabilityInwardsSurfaceLineCollection();
            var context      = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            string textBoxMessage = null;

            DialogBoxHandler = (name, wnd) =>
            {
                var helper = new MessageBoxTester(wnd);
                textBoxMessage = helper.Text;

                if (isActionConfirmed)
                {
                    helper.ClickOk();
                }
                else
                {
                    helper.ClickCancel();
                }
            };

            // Call
            bool updatesVerified = updateInfo.VerifyUpdates(context);

            // Assert
            string expectedInquiryMessage = "Als profielschematisaties wijzigen door het bijwerken, " +
                                            "dan worden de resultaten van berekeningen die deze profielschematisaties gebruiken " +
                                            $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?";

            Assert.AreEqual(expectedInquiryMessage, textBoxMessage);
            Assert.AreEqual(isActionConfirmed, updatesVerified);
            mocks.VerifyAll();
        }
コード例 #8
0
        public void ParameteredConstructor_AssessmentSectionNull_ThrowsArgumentNullException()
        {
            // Setup
            var surfaceLines     = new MacroStabilityInwardsSurfaceLineCollection();
            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            // Call
            TestDelegate test = () => new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(test);

            Assert.AreEqual("assessmentSection", exception.ParamName);
        }
コード例 #9
0
        public void Constructor_WithData_ReturnExpectedValues()
        {
            // Setup
            const string someFilePath = "location/to/a/file";
            var          collection   = new MacroStabilityInwardsSurfaceLineCollection();

            collection.AddRange(Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(), someFilePath);

            // Call
            var properties = new MacroStabilityInwardsSurfaceLineCollectionProperties(collection);

            // Assert
            Assert.IsInstanceOf <ObjectProperties <MacroStabilityInwardsSurfaceLineCollection> >(properties);
            Assert.AreSame(collection, properties.Data);
            Assert.AreEqual(someFilePath, properties.SourcePath);
        }
        public void UpdateSurfaceLinesWithImportedData_WithCurrentLinesAndImportedMultipleLinesWithSameNames_ThrowsUpdateDataException()
        {
            // Setup
            const string duplicateName       = "Duplicate name it is";
            var          expectedSurfaceLine = new MacroStabilityInwardsSurfaceLine(duplicateName);

            Point3D[] expectedGeometry =
            {
                new Point3D(0, 1, 2),
                new Point3D(3, 4, 5),
                new Point3D(6, 7, 8)
            };
            expectedSurfaceLine.SetGeometry(expectedGeometry);

            MacroStabilityInwardsSurfaceLine[] expectedCollection =
            {
                expectedSurfaceLine
            };

            var targetCollection = new MacroStabilityInwardsSurfaceLineCollection();

            targetCollection.AddRange(expectedCollection, sourceFilePath);

            MacroStabilityInwardsSurfaceLine[] importedSurfaceLines =
            {
                new MacroStabilityInwardsSurfaceLine(duplicateName),
                new MacroStabilityInwardsSurfaceLine(duplicateName)
            };

            var strategy = new MacroStabilityInwardsSurfaceLineUpdateDataStrategy(new MacroStabilityInwardsFailureMechanism());

            // Call
            TestDelegate call = () => strategy.UpdateSurfaceLinesWithImportedData(importedSurfaceLines,
                                                                                  sourceFilePath);

            // Assert
            var          exception       = Assert.Throws <UpdateDataException>(call);
            const string expectedMessage = "Geïmporteerde data moet unieke elementen bevatten.";

            Assert.AreEqual(expectedMessage, exception.Message);

            CollectionAssert.AreEqual(expectedCollection, targetCollection);
            MacroStabilityInwardsSurfaceLine actualSurfaceLine = targetCollection[0];

            Assert.AreEqual(expectedSurfaceLine.Name, actualSurfaceLine.Name);
            CollectionAssert.AreEqual(expectedGeometry, actualSurfaceLine.Points);
        }
        public void Text_Always_ReturnsTextFromResource()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism    = new MacroStabilityInwardsFailureMechanism();
            var surfaceLines        = new MacroStabilityInwardsSurfaceLineCollection();
            var surfaceLinesContext = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            // Call
            string text = info.Text(surfaceLinesContext);

            // Assert
            Assert.AreEqual("Profielschematisaties", text);
        }
        public void Image_Always_ReturnsSetImage()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism    = new MacroStabilityInwardsFailureMechanism();
            var surfaceLines        = new MacroStabilityInwardsSurfaceLineCollection();
            var surfaceLinesContext = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            // Call
            Image image = info.Image(surfaceLinesContext);

            // Assert
            TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GeneralFolderIcon, image);
        }
        public void ForeColor_CollectionWithoutSurfaceLines_ReturnsGrayText()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism    = new MacroStabilityInwardsFailureMechanism();
            var surfaceLines        = new MacroStabilityInwardsSurfaceLineCollection();
            var surfaceLinesContext = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            // Call
            Color foreColor = info.ForeColor(surfaceLinesContext);

            // Assert
            Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), foreColor);
        }
コード例 #14
0
        public void ParameteredConstructor_FailureMechanismNull_ThrowsArgumentNullException()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var surfaceLines = new MacroStabilityInwardsSurfaceLineCollection();

            // Call
            TestDelegate call = () => new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, null, assessmentSection);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(call).ParamName;

            Assert.AreEqual("failureMechanism", paramName);
            mocks.VerifyAll();
        }
コード例 #15
0
        public void UpdateSurfaceLinesWithImportedData_DifferentSourcePath_UpdatesSourcePathOfTargetCollection()
        {
            // Setup
            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            MacroStabilityInwardsSurfaceLineCollection targetCollection = failureMechanism.SurfaceLines;
            var          strategy      = new MacroStabilityInwardsSurfaceLineReplaceDataStrategy(failureMechanism);
            const string newSourcePath = "some/other/path";

            // Call
            IEnumerable <IObservable> affectedObjects = strategy.UpdateSurfaceLinesWithImportedData(Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                                                    newSourcePath);

            // Assert
            CollectionAssert.AreEqual(new IObservable[]
            {
                targetCollection
            }, affectedObjects);
            CollectionAssert.IsEmpty(targetCollection);
            Assert.AreEqual(newSourcePath, targetCollection.SourcePath);
        }
        public void IsEnabled_SurfaceLineCollectionSourcePathNull_ReturnFalse()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            var surfaceLines     = new MacroStabilityInwardsSurfaceLineCollection();

            var context = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            // Call
            bool isEnabled = updateInfo.IsEnabled(context);

            // Assert
            Assert.IsFalse(isEnabled);
            mocks.VerifyAll();
        }
        public void CreateFileImporter_ValidInput_ReturnFileImporter()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine());
            mocks.ReplayAll();

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            var surfaceLines     = new MacroStabilityInwardsSurfaceLineCollection();

            var importTarget = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            // Call
            IFileImporter importer = updateInfo.CreateFileImporter(importTarget, "");

            // Assert
            Assert.IsInstanceOf <SurfaceLinesCsvImporter <MacroStabilityInwardsSurfaceLine> >(importer);
            mocks.VerifyAll();
        }
コード例 #18
0
        public void IsEnabled_ReferenceLineWithoutGeometry_ReturnFalse()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine());
            mocks.ReplayAll();

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            var surfaceLines     = new MacroStabilityInwardsSurfaceLineCollection();

            var context = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            // Call
            bool isEnabled = importInfo.IsEnabled(context);

            // Assert
            Assert.IsFalse(isEnabled);
            mocks.VerifyAll();
        }
コード例 #19
0
        public void ParameteredConstructor_DefaultValues()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            var surfaceLines = new MacroStabilityInwardsSurfaceLineCollection();

            // Call
            var context = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            // Assert
            Assert.IsInstanceOf <ObservableWrappedObjectContextBase <MacroStabilityInwardsSurfaceLineCollection> >(context);
            Assert.AreSame(surfaceLines, context.WrappedData);
            Assert.AreSame(assessmentSection, context.AssessmentSection);
            mocks.VerifyAll();
        }
        public void IsEnabled_SurfaceLineCollectionSourcePathSet_ReturnTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            var surfaceLines     = new MacroStabilityInwardsSurfaceLineCollection();

            surfaceLines.AddRange(Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(), "some/path");

            var context = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            // Call
            bool isEnabled = updateInfo.IsEnabled(context);

            // Assert
            Assert.IsTrue(isEnabled);
            mocks.VerifyAll();
        }
        public void CreateInstance_WithContext_NewPropertiesWithInputContextAsData()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            var collection = new MacroStabilityInwardsSurfaceLineCollection();
            var context    = new MacroStabilityInwardsSurfaceLinesContext(collection, failureMechanism, assessmentSection);

            // Call
            IObjectProperties objectProperties = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <MacroStabilityInwardsSurfaceLineCollectionProperties>(objectProperties);
            Assert.AreSame(collection, objectProperties.Data);

            mocks.VerifyAll();
        }
        public void UpdateSurfaceLinesWithImportedData_CalculationWithOutputAndAssignedLineDeleted_ClearsCalculationOutput()
        {
            // Setup
            MacroStabilityInwardsSurfaceLine surfaceLine = CreateValidSurfaceLineForCalculations();
            var calculation = new MacroStabilityInwardsCalculation
            {
                InputParameters =
                {
                    SurfaceLine = surfaceLine
                },
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            };

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(calculation);
            MacroStabilityInwardsSurfaceLineCollection surfaceLineCollection = failureMechanism.SurfaceLines;

            surfaceLineCollection.AddRange(new[]
            {
                surfaceLine
            }, sourceFilePath);

            var strategy = new MacroStabilityInwardsSurfaceLineUpdateDataStrategy(failureMechanism);

            // Call
            IEnumerable <IObservable> affectedObjects = strategy.UpdateSurfaceLinesWithImportedData(Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                                                    sourceFilePath).ToArray();

            // Assert
            Assert.IsFalse(calculation.HasOutput);
            Assert.IsNull(calculation.InputParameters.SurfaceLine);
            CollectionAssert.AreEquivalent(new IObservable[]
            {
                surfaceLineCollection,
                calculation,
                calculation.InputParameters
            }, affectedObjects);
        }
        public void UpdateSurfaceLinesWithImportedData_OnlyGeometryChanged_UpdatesGeometryOnly()
        {
            // Setup
            MacroStabilityInwardsSurfaceLine surfaceLine = CreateValidSurfaceLineForCalculations();

            MacroStabilityInwardsSurfaceLine surfaceLineToUpdateFrom = CreateValidSurfaceLineForCalculations();
            var expectedGeometry = new List <Point3D>
            {
                new Point3D(0, 1, 2),
                new Point3D(3, 4, 5),
                new Point3D(6, 7, 8)
            };

            expectedGeometry.AddRange(surfaceLine.Points);
            surfaceLineToUpdateFrom.SetGeometry(expectedGeometry);

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            MacroStabilityInwardsSurfaceLineCollection targetCollection = failureMechanism.SurfaceLines;

            targetCollection.AddRange(new[]
            {
                surfaceLine
            }, sourceFilePath);
            var strategy = new MacroStabilityInwardsSurfaceLineUpdateDataStrategy(failureMechanism);

            // Call
            strategy.UpdateSurfaceLinesWithImportedData(new[]
            {
                surfaceLineToUpdateFrom
            },
                                                        sourceFilePath);

            // Assert
            Assert.AreEqual(surfaceLineToUpdateFrom.Name, surfaceLine.Name);
            Assert.AreEqual(surfaceLineToUpdateFrom.ReferenceLineIntersectionWorldPoint,
                            surfaceLine.ReferenceLineIntersectionWorldPoint);
            CollectionAssert.AreEqual(surfaceLineToUpdateFrom.Points, surfaceLine.Points);
        }
        public void UpdateSurfaceLinesWithImportedData_WithoutCurrentSurfaceLinesAndReadLinesHaveDuplicateNames_ThrowsUpdateDataException()
        {
            // Setup
            const string duplicateName = "Duplicate name it is";
            var          lineOne       = new MacroStabilityInwardsSurfaceLine(duplicateName);

            lineOne.SetGeometry(new[]
            {
                new Point3D(1, 2, 3)
            });
            var lineTwo = new MacroStabilityInwardsSurfaceLine(duplicateName);

            lineTwo.SetGeometry(new[]
            {
                new Point3D(4, 5, 6)
            });
            MacroStabilityInwardsSurfaceLine[] importedSurfaceLines =
            {
                lineOne,
                lineTwo
            };

            var targetCollection = new MacroStabilityInwardsSurfaceLineCollection();
            var strategy         = new MacroStabilityInwardsSurfaceLineUpdateDataStrategy(new MacroStabilityInwardsFailureMechanism());

            // Call
            TestDelegate call = () => strategy.UpdateSurfaceLinesWithImportedData(importedSurfaceLines,
                                                                                  sourceFilePath);

            // Assert
            var exception = Assert.Throws <UpdateDataException>(call);

            const string expectedMessage = "Geïmporteerde data moet unieke elementen bevatten.";

            Assert.AreEqual(expectedMessage, exception.Message);

            CollectionAssert.IsEmpty(targetCollection);
        }
        public void UpdateSurfaceLinesWithImportedData_WithCurrentCollectionNotEmptyAndImportedDataHasFullOverlap_UpdatesTargetCollection()
        {
            // Setup
            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            const string collectionSurfaceLineName = "Name A";
            var          targetSurfaceLine         = new MacroStabilityInwardsSurfaceLine(collectionSurfaceLineName);
            MacroStabilityInwardsSurfaceLineCollection targetCollection = failureMechanism.SurfaceLines;

            targetCollection.AddRange(new[]
            {
                targetSurfaceLine
            }, sourceFilePath);

            MacroStabilityInwardsSurfaceLine readSurfaceLine = DeepCloneAndModifyPoints(targetSurfaceLine);

            MacroStabilityInwardsSurfaceLine[] readSurfaceLines =
            {
                readSurfaceLine
            };

            var strategy = new MacroStabilityInwardsSurfaceLineUpdateDataStrategy(failureMechanism);

            // Call
            IEnumerable <IObservable> affectedObjects = strategy.UpdateSurfaceLinesWithImportedData(readSurfaceLines,
                                                                                                    sourceFilePath);

            // Assert
            Assert.AreEqual(1, targetCollection.Count);
            Assert.AreSame(targetSurfaceLine, targetCollection[0]);
            Assert.AreEqual(readSurfaceLine, targetSurfaceLine);

            CollectionAssert.AreEqual(new IObservable[]
            {
                targetCollection,
                targetSurfaceLine
            }, affectedObjects);
        }
コード例 #26
0
        public void Constructor_WithData_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var collection = new MacroStabilityInwardsSurfaceLineCollection();

            // Call
            var properties = new MacroStabilityInwardsSurfaceLineCollectionProperties(collection);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(1, dynamicProperties.Count);

            PropertyDescriptor surfaceLineCollectionProperty = dynamicProperties[0];

            Assert.IsNotNull(surfaceLineCollectionProperty);
            Assert.IsTrue(surfaceLineCollectionProperty.IsReadOnly);
            Assert.AreEqual("Algemeen", surfaceLineCollectionProperty.Category);
            Assert.AreEqual("Bronlocatie", surfaceLineCollectionProperty.DisplayName);
            Assert.AreEqual(
                "De locatie van het bestand waaruit de profielschematisaties zijn geïmporteerd.",
                surfaceLineCollectionProperty.Description);
        }
コード例 #27
0
        public void UpdateSurfaceLinesWithImportedData_NoCurrentLinesWithImportedData_AddsNewSurfaceLines()
        {
            // Setup
            var importedSurfaceLines = new[]
            {
                new MacroStabilityInwardsSurfaceLine(string.Empty)
            };

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            var strategy         = new MacroStabilityInwardsSurfaceLineReplaceDataStrategy(failureMechanism);

            // Call
            IEnumerable <IObservable> affectedObjects = strategy.UpdateSurfaceLinesWithImportedData(importedSurfaceLines,
                                                                                                    sourceFilePath);

            // Assert
            MacroStabilityInwardsSurfaceLineCollection actualCollection = failureMechanism.SurfaceLines;

            CollectionAssert.AreEqual(importedSurfaceLines, actualCollection);
            CollectionAssert.AreEqual(new[]
            {
                actualCollection
            }, affectedObjects);
        }
        public void UpdateSurfaceLinesWithImportedData_MultipleCalculationsWithSurfaceLinesOneWithRemovedLine_OnlyUpdatesCalculationWithRemovedSurfaceLine()
        {
            // Setup
            const string removedSurfaceLineName    = "Name A";
            const string unaffectedSurfaceLineName = "Name B";

            var removedSurfaceLine = new MacroStabilityInwardsSurfaceLine(removedSurfaceLineName);

            removedSurfaceLine.SetGeometry(new[]
            {
                new Point3D(1, 2, 3),
                new Point3D(4, 5, 6)
            });
            var affectedCalculation = new MacroStabilityInwardsCalculation
            {
                InputParameters =
                {
                    SurfaceLine = removedSurfaceLine
                },
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            };

            var unaffectedGeometry = new[]
            {
                new Point3D(10, 9, 8),
                new Point3D(7, 6, 5)
            };
            var unaffectedSurfaceLine = new MacroStabilityInwardsSurfaceLine(unaffectedSurfaceLineName);

            unaffectedSurfaceLine.SetGeometry(unaffectedGeometry);
            var unAffectedCalculation = new MacroStabilityInwardsCalculation
            {
                InputParameters =
                {
                    SurfaceLine = unaffectedSurfaceLine
                },
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            };

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            MacroStabilityInwardsSurfaceLineCollection collection = failureMechanism.SurfaceLines;

            collection.AddRange(new[]
            {
                removedSurfaceLine,
                unaffectedSurfaceLine
            }, sourceFilePath);
            failureMechanism.CalculationsGroup.Children.Add(affectedCalculation);
            failureMechanism.CalculationsGroup.Children.Add(unAffectedCalculation);

            MacroStabilityInwardsSurfaceLine importedUnaffectedSurfaceLine = DeepCloneName(unaffectedSurfaceLine);

            importedUnaffectedSurfaceLine.SetGeometry(unaffectedGeometry);

            var strategy = new MacroStabilityInwardsSurfaceLineUpdateDataStrategy(failureMechanism);

            // Call
            IEnumerable <IObservable> affectedObjects = strategy.UpdateSurfaceLinesWithImportedData(new[]
            {
                importedUnaffectedSurfaceLine
            }, "path").ToArray();

            // Assert
            Assert.IsTrue(unAffectedCalculation.HasOutput);
            MacroStabilityInwardsInput unaffectedInput = unAffectedCalculation.InputParameters;

            Assert.AreSame(unaffectedSurfaceLine, unaffectedInput.SurfaceLine);
            Assert.AreEqual(unaffectedSurfaceLine, unaffectedInput.SurfaceLine);

            Assert.IsFalse(affectedCalculation.HasOutput);
            MacroStabilityInwardsInput affectedInput = affectedCalculation.InputParameters;

            Assert.IsNull(affectedInput.SurfaceLine);

            CollectionAssert.AreEquivalent(new IObservable[]
            {
                collection,
                affectedCalculation,
                affectedInput
            }, affectedObjects);
        }
コード例 #29
0
        private void SetSurfaceLinesMapData()
        {
            MacroStabilityInwardsSurfaceLineCollection macroStabilityInwardsSurfaceLines = FailureMechanism.SurfaceLines;

            surfaceLinesMapData.Features = MacroStabilityInwardsMapDataFeaturesFactory.CreateSurfaceLineFeatures(macroStabilityInwardsSurfaceLines.ToArray());
        }