Beispiel #1
0
        public void CreateFileImporter_Always_ReturnFileImporter()
        {
            // Setup
            var mocks = new MockRepository();
            IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);

            mocks.ReplayAll();

            var context = new StabilityPointStructuresCalculationGroupContext(new CalculationGroup(),
                                                                              null,
                                                                              new StabilityPointStructuresFailureMechanism(),
                                                                              assessmentSection);

            using (var plugin = new StabilityPointStructuresPlugin())
            {
                ImportInfo info = GetImportInfo(plugin);

                // Call
                IFileImporter fileImporter = info.CreateFileImporter(context, "test");

                // Assert
                Assert.IsInstanceOf <StabilityPointStructuresCalculationConfigurationImporter>(fileImporter);
            }

            mocks.VerifyAll();
        }
        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 TestStabilityPointStructuresCalculationScenario());
            }

            var context = new StabilityPointStructuresCalculationGroupContext(calculationGroup,
                                                                              null,
                                                                              new StabilityPointStructuresFailureMechanism(),
                                                                              assessmentSection);

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

            // Assert
            Assert.IsTrue(isEnabled);
        }
Beispiel #3
0
        public void ParameteredConstructor_ExpectedValues(bool hasParent)
        {
            // Setup
            var mockRepository    = new MockRepository();
            var assessmentSection = mockRepository.Stub <IAssessmentSection>();

            mockRepository.ReplayAll();

            var calculationGroup = new CalculationGroup();
            var failureMechanism = new StabilityPointStructuresFailureMechanism();

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

            // Call
            var groupContext = new StabilityPointStructuresCalculationGroupContext(calculationGroup, parent, failureMechanism, assessmentSection);

            // Assert
            Assert.IsInstanceOf <FailureMechanismItemContextBase <CalculationGroup, StabilityPointStructuresFailureMechanism> >(groupContext);
            Assert.IsInstanceOf <ICalculationContext <CalculationGroup, StabilityPointStructuresFailureMechanism> >(groupContext);
            Assert.AreSame(calculationGroup, groupContext.WrappedData);
            Assert.AreSame(parent, groupContext.Parent);
            Assert.AreSame(failureMechanism, groupContext.FailureMechanism);
            Assert.AreSame(assessmentSection, groupContext.AssessmentSection);
            Assert.AreSame(failureMechanism.ForeshoreProfiles, groupContext.AvailableForeshoreProfiles);
            Assert.AreSame(failureMechanism.StabilityPointStructures, groupContext.AvailableStructures);
            mockRepository.VerifyAll();
        }
Beispiel #4
0
        public void AdditionalDataCheck_CalculationGroupContextWithFailureMechanismParent_ReturnsTrue()
        {
            // Setup
            var assessmentSection       = new AssessmentSectionStub();
            var failureMechanism        = new StabilityPointStructuresFailureMechanism();
            var calculationGroupContext = new StabilityPointStructuresCalculationGroupContext(failureMechanism.CalculationsGroup,
                                                                                              null,
                                                                                              failureMechanism,
                                                                                              assessmentSection);

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

            // Assert
            Assert.IsTrue(additionalDataCheck);
        }
Beispiel #5
0
        public void GetViewData_ContextNotNull_ReturnsWrappedCalculationGroup()
        {
            // Setup
            var assessmentSection       = new AssessmentSectionStub();
            var failureMechanism        = new StabilityPointStructuresFailureMechanism();
            var calculationGroup        = new CalculationGroup();
            var calculationGroupContext = new StabilityPointStructuresCalculationGroupContext(calculationGroup,
                                                                                              null,
                                                                                              failureMechanism,
                                                                                              assessmentSection);

            // Call
            object viewData = info.GetViewData(calculationGroupContext);

            // Assert
            Assert.AreSame(calculationGroup, viewData);
        }
        public void CreateFileExporter_Always_ReturnFileExporter()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new StabilityPointStructuresCalculationGroupContext(new CalculationGroup(),
                                                                              null,
                                                                              new StabilityPointStructuresFailureMechanism(),
                                                                              assessmentSection);

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

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

            mocks.ReplayAll();

            var context = new StabilityPointStructuresCalculationGroupContext(new CalculationGroup(),
                                                                              null,
                                                                              new StabilityPointStructuresFailureMechanism(),
                                                                              assessmentSection);

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

            // Assert
            Assert.IsFalse(isEnabled);
        }
Beispiel #8
0
        public void GetViewName_WithCalculationGroupContext_ReturnsCalculationGroupName()
        {
            // Setup
            var          assessmentSection    = new AssessmentSectionStub();
            const string calculationGroupName = "Test";

            var calculationGroup = new CalculationGroup
            {
                Name = calculationGroupName
            };

            var calculationGroupContext = new StabilityPointStructuresCalculationGroupContext(calculationGroup,
                                                                                              null,
                                                                                              new StabilityPointStructuresFailureMechanism(),
                                                                                              assessmentSection);
            // Call
            string name = info.GetViewName(null, calculationGroupContext);

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