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

            mocks.ReplayAll();

            var calculation = new MacroStabilityInwardsCalculationScenario
            {
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            };

            var nestedGroup = new CalculationGroup();

            nestedGroup.Children.Add(calculation);
            nestedGroup.Children.Add(new MacroStabilityInwardsCalculationScenario());

            var calculationGroup = new CalculationGroup();

            calculationGroup.Children.Add(nestedGroup);

            var context = new MacroStabilityInwardsCalculationGroupContext(calculationGroup,
                                                                           null,
                                                                           Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                           Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(),
                                                                           new MacroStabilityInwardsFailureMechanism(),
                                                                           assessmentSection);

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

            // Assert
            Assert.IsTrue(isEnabled);
        }
Exemplo n.º 2
0
        public void IsEnabled_CalculationGroupWithChildren_ReturnTrue(bool hasNestedGroup, bool hasCalculation)
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var calculationGroup = new CalculationGroup();

            if (hasNestedGroup)
            {
                calculationGroup.Children.Add(new CalculationGroup());
            }

            if (hasCalculation)
            {
                calculationGroup.Children.Add(new MacroStabilityInwardsCalculation());
            }

            var context = new MacroStabilityInwardsCalculationGroupContext(calculationGroup,
                                                                           null,
                                                                           Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                           Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(),
                                                                           new MacroStabilityInwardsFailureMechanism(),
                                                                           assessmentSection);

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

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

            mocks.ReplayAll();

            var calculation = new MacroStabilityInwardsCalculationScenario();
            var nestedGroup = new CalculationGroup();

            nestedGroup.Children.Add(calculation);
            var calculationGroup = new CalculationGroup();

            calculationGroup.Children.Add(nestedGroup);

            var calculationGroupContext = new MacroStabilityInwardsCalculationGroupContext(new CalculationGroup(),
                                                                                           null,
                                                                                           Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                                           Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(),
                                                                                           new MacroStabilityInwardsFailureMechanism(),
                                                                                           assessmentSection);

            using (var view = new MacroStabilityInwardsInputView(calculation,
                                                                 new GeneralMacroStabilityInwardsInput(),
                                                                 assessmentSection,
                                                                 GetHydraulicBoundaryLocationCalculation))
            {
                // Call
                bool closeForData = info.CloseForData(view, calculationGroupContext);

                // Assert
                Assert.IsFalse(closeForData);
                mocks.VerifyAll();
            }
        }
        public void OnNodeRemoved_ParentIsCalculationGroupContext_RemoveCalculationFromGroup()
        {
            // Setup
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());

            var elementToBeRemoved = new MacroStabilityInwardsCalculationScenario();

            var group = new CalculationGroup();

            group.Children.Add(elementToBeRemoved);
            group.Children.Add(new MacroStabilityInwardsCalculationScenario());
            group.Attach(observer);

            var failureMechanism  = new MacroStabilityInwardsFailureMechanism();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var calculationContext = new MacroStabilityInwardsCalculationScenarioContext(elementToBeRemoved,
                                                                                         group,
                                                                                         Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                                         Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(),
                                                                                         failureMechanism,
                                                                                         assessmentSection);
            var groupContext = new MacroStabilityInwardsCalculationGroupContext(group,
                                                                                null,
                                                                                Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                                Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(),
                                                                                failureMechanism,
                                                                                assessmentSection);

            // Precondition
            Assert.IsTrue(info.CanRemove(calculationContext, groupContext));
            Assert.AreEqual(2, group.Children.Count);

            // Call
            info.OnNodeRemoved(calculationContext, groupContext);

            // Assert
            Assert.AreEqual(1, group.Children.Count);
            CollectionAssert.DoesNotContain(group.Children, elementToBeRemoved);
        }
        public void ParameteredConstructor_ExpectedValues(bool hasParent)
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var calculationGroup = new CalculationGroup();
            var surfaceLines     = new[]
            {
                new MacroStabilityInwardsSurfaceLine(string.Empty)
            };

            MacroStabilityInwardsStochasticSoilModel[] soilModels =
            {
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel()
            };

            CalculationGroup parent = hasParent ? new CalculationGroup() : null;

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            // Call
            var groupContext = new MacroStabilityInwardsCalculationGroupContext(calculationGroup,
                                                                                parent,
                                                                                surfaceLines,
                                                                                soilModels,
                                                                                failureMechanism,
                                                                                assessmentSection);

            // Assert
            Assert.IsInstanceOf <MacroStabilityInwardsContext <CalculationGroup> >(groupContext);
            Assert.IsInstanceOf <ICalculationContext <CalculationGroup, MacroStabilityInwardsFailureMechanism> >(groupContext);
            Assert.AreSame(calculationGroup, groupContext.WrappedData);
            Assert.AreSame(parent, groupContext.Parent);
            Assert.AreSame(surfaceLines, groupContext.AvailableMacroStabilityInwardsSurfaceLines);
            Assert.AreSame(soilModels, groupContext.AvailableStochasticSoilModels);
            Assert.AreSame(failureMechanism, groupContext.FailureMechanism);
            Assert.AreSame(assessmentSection, groupContext.AssessmentSection);
            mocks.VerifyAll();
        }
        public void CreateFileExporter_WithContext_ReturnFileExporter()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new MacroStabilityInwardsCalculationGroupContext(new CalculationGroup(),
                                                                           null,
                                                                           Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                           Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(),
                                                                           new MacroStabilityInwardsFailureMechanism(),
                                                                           assessmentSection);

            // Call
            IFileExporter fileExporter = info.CreateFileExporter(context, "test");

            // Assert
            Assert.IsInstanceOf <MacroStabilityInwardsCalculationGroupExporter>(fileExporter);
        }
        public void IsEnabled_CalculationGroupNoChildren_ReturnFalse()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new MacroStabilityInwardsCalculationGroupContext(new CalculationGroup(),
                                                                           null,
                                                                           Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                           Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(),
                                                                           new MacroStabilityInwardsFailureMechanism(),
                                                                           assessmentSection);

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

            // Assert
            Assert.IsFalse(isEnabled);
        }
Exemplo n.º 8
0
        public void GetViewData_Always_ReturnsWrappedCalculationGroup()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism        = new MacroStabilityInwardsFailureMechanism();
            var calculationGroup        = new CalculationGroup();
            var calculationGroupContext = new MacroStabilityInwardsCalculationGroupContext(calculationGroup,
                                                                                           null,
                                                                                           Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                                           Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(),
                                                                                           failureMechanism,
                                                                                           assessmentSection);

            // Call & Assert
            Assert.AreSame(calculationGroup, info.GetViewData(calculationGroupContext));
            mocks.VerifyAll();
        }
Exemplo n.º 9
0
        public void AdditionalDataCheck_CalculationGroupContextWithFailureMechanismParent_ReturnsTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            var context          = new MacroStabilityInwardsCalculationGroupContext(failureMechanism.CalculationsGroup,
                                                                                    null,
                                                                                    Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                                    Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(),
                                                                                    failureMechanism,
                                                                                    assessmentSection);

            // Call
            bool additionalDataCheck = info.AdditionalDataCheck(context);

            // Assert
            Assert.IsTrue(additionalDataCheck);
            mocks.VerifyAll();
        }
Exemplo n.º 10
0
        public void CreateFileImporter_Always_ReturnFileImporter()
        {
            // Setup
            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            var mocks = new MockRepository();
            IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);

            mocks.ReplayAll();

            var context = new MacroStabilityInwardsCalculationGroupContext(new CalculationGroup(),
                                                                           null,
                                                                           Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                           Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(),
                                                                           failureMechanism,
                                                                           assessmentSection);

            // Call
            IFileImporter importer = importInfo.CreateFileImporter(context, "");

            // Assert
            Assert.IsInstanceOf <MacroStabilityInwardsCalculationConfigurationImporter>(importer);
            mocks.VerifyAll();
        }
Exemplo n.º 11
0
        public void GetViewName_WithContext_ReturnsCalculationGroupName()
        {
            // Setup
            const string calculationGroupName = "Test";

            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

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

            var calculationGroup = new CalculationGroup
            {
                Name = calculationGroupName
            };

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            using (var calculationsView = new MacroStabilityInwardsCalculationsView(calculationGroup, failureMechanism, assessmentSection))
            {
                var context = new MacroStabilityInwardsCalculationGroupContext(calculationGroup,
                                                                               null,
                                                                               Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                               Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(),
                                                                               failureMechanism,
                                                                               assessmentSection);

                // Call
                string name = info.GetViewName(calculationsView, context);

                // Assert
                Assert.AreEqual(calculationGroupName, name);
            }

            mocks.VerifyAll();
        }