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

            mocks.ReplayAll();

            var failureMechanism = new DuneErosionFailureMechanism();

            failureMechanism.SetDuneLocations(new[]
            {
                new TestDuneLocation()
            });
            var context = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList <DuneLocationCalculationsForTargetProbability>(),
                                                                                                    failureMechanism,
                                                                                                    assessmentSection);

            using (var plugin = new DuneErosionPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

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

                // Assert
                Assert.IsFalse(isEnabled);
            }

            mocks.VerifyAll();
        }
コード例 #2
0
        public void CreateCalculationConfigurationExportInfo_WithArguments_ExpectedPropertiesSet()
        {
            // Setup
            var mocks         = new MockRepository();
            var fileImporter  = mocks.Stub <IFileExporter>();
            var inquiryHelper = mocks.Stub <IInquiryHelper>();

            mocks.ReplayAll();

            Func <ICalculationContext <ICalculation, ICalculatableFailureMechanism>, string, IFileExporter> createFileExporter = (context, s) => fileImporter;

            // Call
            ExportInfo <ICalculationContext <ICalculation, ICalculatableFailureMechanism> > exportInfo =
                RiskeerExportInfoFactory.CreateCalculationConfigurationExportInfo(createFileExporter, inquiryHelper);

            // Assert
            Assert.AreSame(createFileExporter, exportInfo.CreateFileExporter);
            Assert.AreEqual("Riskeer berekeningenconfiguratie", exportInfo.Name(null));
            Assert.AreEqual("xml", exportInfo.Extension);
            Assert.AreEqual("Algemeen", exportInfo.Category);

            TestHelper.AssertImagesAreEqual(CoreGuiResources.ExportIcon, exportInfo.Image);
            Assert.IsTrue(exportInfo.IsEnabled(null));

            Assert.IsNotNull(exportInfo.GetExportPath);

            mocks.VerifyAll();
        }
コード例 #3
0
        public void IsEnabled_ContextWithTargetProbabilities_ReturnsTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new WaveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext(
                new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>
            {
                new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1)
            }, assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

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

                // Assert
                Assert.IsTrue(isEnabled);
            }

            mocks.VerifyAll();
        }
コード例 #4
0
        public void IsEnabled_CalculationWithoutOutput_ReturnFalse()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new StabilityStoneCoverWaveConditionsCalculationContext(new StabilityStoneCoverWaveConditionsCalculation(),
                                                                                  new CalculationGroup(),
                                                                                  new StabilityStoneCoverFailureMechanism(),
                                                                                  assessmentSection);

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

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

            mocks.ReplayAll();

            var context = new GrassCoverErosionOutwardsCalculationGroupContext(new CalculationGroup(),
                                                                               null,
                                                                               new GrassCoverErosionOutwardsFailureMechanism(),
                                                                               assessmentSection);

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

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

            mocks.ReplayAll();

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

            var context = new StabilityStoneCoverCalculationGroupContext(calculationGroup, null, failureMechanism, assessmentSection);

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

            // Assert
            Assert.IsFalse(isEnabled);
        }
        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);
        }
        public void IsEnabled_Always_ReturnsTrue()
        {
            // Setup
            using (var plugin = new RiskeerPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

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

                // Assert
                Assert.IsTrue(isEnabled);
            }
        }
コード例 #9
0
ファイル: ExportInfoTest.cs プロジェクト: Deltares/Riskeer
        public void ImplicitOperator_OptionalDelegatesAndPropertiesSet_ExportInfoFullyConverted()
        {
            // Setup
            var mocks        = new MockRepository();
            var fileExporter = mocks.StrictMock <IFileExporter>();

            mocks.ReplayAll();

            const string name       = "name";
            const string extension  = ".txt";
            const string category   = "category";
            var          image      = new Bitmap(16, 16);
            const string exportPath = "C:/path";

            var info = new ExportInfo <int>
            {
                CreateFileExporter = (data, filePath) => fileExporter,
                IsEnabled          = data => false,
                Name          = data => name,
                Extension     = extension,
                Category      = category,
                Image         = image,
                GetExportPath = () => exportPath
            };

            // Precondition
            Assert.IsInstanceOf <ExportInfo <int> >(info);

            // Call
            ExportInfo convertedInfo = info;

            // Assert
            Assert.IsInstanceOf <ExportInfo>(convertedInfo);
            Assert.AreEqual(typeof(int), convertedInfo.DataType);
            Assert.IsNotNull(convertedInfo.CreateFileExporter);
            Assert.AreSame(fileExporter, convertedInfo.CreateFileExporter(12, string.Empty));
            Assert.IsNotNull(convertedInfo.IsEnabled);
            Assert.IsFalse(convertedInfo.IsEnabled(12));
            Assert.AreEqual(name, info.Name(12));
            Assert.AreEqual(extension, info.Extension);
            Assert.AreEqual(category, info.Category);
            Assert.AreSame(image, info.Image);
            Assert.AreEqual(exportPath, info.GetExportPath());

            mocks.VerifyAll();
        }
コード例 #10
0
        public void IsEnabled_HydraulicBoundaryDatabaseNotLinked_ReturnFalse()
        {
            // Setup
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
            var context           = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

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

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

            mocks.ReplayAll();

            var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(new GrassCoverErosionOutwardsWaveConditionsCalculation(),
                                                                                        new CalculationGroup(),
                                                                                        new GrassCoverErosionOutwardsFailureMechanism(),
                                                                                        assessmentSection);

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

            // Assert
            Assert.IsTrue(isEnabled);
        }
コード例 #12
0
        public void IsEnabled_Always_ReturnsFalse()
        {
            // Setup
            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>());
            var context           = new AssemblyResultsContext(assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

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

                // Assert
                Assert.IsFalse(isEnabled);
            }
        }
コード例 #13
0
        public void IsEnabled_Always_ReturnTrue()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new StabilityPointStructuresCalculationScenarioContext(new TestStabilityPointStructuresCalculationScenario(),
                                                                                 new CalculationGroup(),
                                                                                 new StabilityPointStructuresFailureMechanism(),
                                                                                 assessmentSection);

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

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

            mocks.ReplayAll();

            var context = new SemiProbabilisticPipingCalculationScenarioContext(new SemiProbabilisticPipingCalculationScenario(),
                                                                                new CalculationGroup(),
                                                                                Enumerable.Empty <PipingSurfaceLine>(),
                                                                                Enumerable.Empty <PipingStochasticSoilModel>(),
                                                                                new PipingFailureMechanism(),
                                                                                assessmentSection);

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

            // Assert
            Assert.IsTrue(isEnabled);
        }
コード例 #15
0
ファイル: ExportInfoTest.cs プロジェクト: Deltares/Riskeer
        public void ImplicitOperator_NoneOfTheOptionalDelegatesAndPropertiesSet_ExportInfoFullyConverted()
        {
            // Setup
            var info = new ExportInfo <int>();

            // Precondition
            Assert.IsInstanceOf <ExportInfo <int> >(info);

            // Call
            ExportInfo convertedInfo = info;

            // Assert
            Assert.IsInstanceOf <ExportInfo>(convertedInfo);
            Assert.AreEqual(typeof(int), convertedInfo.DataType);
            Assert.IsNotNull(convertedInfo.CreateFileExporter);
            Assert.IsNull(convertedInfo.CreateFileExporter(new object(), string.Empty));
            Assert.IsNotNull(convertedInfo.IsEnabled);
            Assert.IsTrue(convertedInfo.IsEnabled(new object()));
            Assert.IsNull(info.Name);
            Assert.IsNull(info.Extension);
            Assert.AreEqual("Algemeen", info.Category);
            TestHelper.AssertImagesAreEqual(Resources.ExportIcon, info.Image);
            Assert.IsNull(info.GetExportPath);
        }
        public void IsEnabled_CalculationsWithOutput_ReturnTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var calculationsForTargetProbability = new DuneLocationCalculationsForTargetProbability(0.1)
            {
                DuneLocationCalculations =
                {
                    new DuneLocationCalculation(new TestDuneLocation())
                    {
                        Output = new TestDuneLocationCalculationOutput()
                    }
                }
            };

            var context = new DuneLocationCalculationsForUserDefinedTargetProbabilityContext(calculationsForTargetProbability,
                                                                                             new DuneErosionFailureMechanism(),
                                                                                             assessmentSection);

            using (var plugin = new DuneErosionPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

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

                // Assert
                Assert.IsTrue(isEnabled);
            }

            mocks.VerifyAll();
        }
コード例 #17
0
        public void IsEnabled_ReferenceLineWithGeometry_ReturnTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

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

            var context = new ReferenceLineContext(assessmentSection.ReferenceLine, assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

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

                // Assert
                Assert.IsTrue(isEnabled);
            }

            mocks.VerifyAll();
        }