예제 #1
0
        private static void ExportItem(ExportInfo exportInfo, object source)
        {
            string exportFilePath = exportInfo.GetExportPath();
            string exportInfoName = exportInfo.Name(source);

            if (exportFilePath != null)
            {
                log.InfoFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Start_exporting_DataType_0_,
                               exportInfoName);

                IFileExporter exporter = exportInfo.CreateFileExporter(source, exportFilePath);

                if (exporter.Export())
                {
                    log.InfoFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Data_exported_to_File_0, exportFilePath);
                    log.InfoFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Export_of_DataType_0_successful,
                                   exportInfoName);
                }
                else
                {
                    log.ErrorFormat(Resources.GuiExportHandler_ExportItemUsingDialog_Export_of_DataType_0_failed,
                                    exportInfoName);
                }
            }
        }
예제 #2
0
        public void CreateFileExporter_WithContext_ReturnFileExporter()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

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

            const string filePath = "test";

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

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

                // Assert
                Assert.IsInstanceOf <HydraulicBoundaryLocationCalculationsForTargetProbabilitiesExporter>(fileExporter);
            }

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

            mocks.ReplayAll();

            var context = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList <DuneLocationCalculationsForTargetProbability>(),
                                                                                                    new DuneErosionFailureMechanism(),
                                                                                                    assessmentSection);

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

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

                // Assert
                Assert.IsInstanceOf <DuneLocationCalculationsExporter>(fileExporter);
            }

            mocks.VerifyAll();
        }
예제 #4
0
        public void CreateFileExporter_Always_ReturnFileExporter()
        {
            // Setup
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
            {
                HydraulicBoundaryDatabase =
                {
                    Locations =
                    {
                        new HydraulicBoundaryLocation(1, "test", 0, 0)
                    }
                }
            };
            var          context  = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection);
            const string filePath = "test";

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

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

                // Assert
                Assert.IsInstanceOf <HydraulicBoundaryLocationCalculationsExporter>(fileExporter);
            }
        }
예제 #5
0
        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();
        }
예제 #6
0
        public void CreateFileExporter_Always_ReturnFileExporter()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

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

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

            // Assert
            Assert.IsInstanceOf <StabilityPointStructuresCalculationConfigurationExporter>(fileExporter);
        }
예제 #7
0
        public void CreateFileExporter_Always_ReturnFileExporter()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

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

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

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

            mocks.ReplayAll();

            var context = new GrassCoverErosionInwardsCalculationGroupContext(new CalculationGroup(),
                                                                              null,
                                                                              new GrassCoverErosionInwardsFailureMechanism(),
                                                                              assessmentSection);

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

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

            mocks.ReplayAll();

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

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

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

            // Assert
            Assert.IsInstanceOf <WaveConditionsExporterBase>(fileExporter);
        }
예제 #10
0
        public void CreateFileExporter_Always_ReturnFileExporter()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            assessmentSection.Stub(section => section.FailureMechanismContribution).Return(new FailureMechanismContribution(0.1, 0.1));
            mocks.ReplayAll();

            var context = new WaveImpactAsphaltCoverCalculationGroupContext(new CalculationGroup(),
                                                                            null,
                                                                            new WaveImpactAsphaltCoverFailureMechanism(),
                                                                            assessmentSection);

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

            // Assert
            Assert.IsInstanceOf <WaveImpactAsphaltCoverWaveConditionsCalculationConfigurationExporter>(fileExporter);
        }
        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 CreateFileExporter_Always_ReturnFileExporter()
        {
            // 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
            IFileExporter fileExporter = info.CreateFileExporter(context, "test");

            // Assert
            Assert.IsInstanceOf <PipingCalculationConfigurationExporter>(fileExporter);
        }
예제 #13
0
        public void CreateFileExporter_Always_ReturnFileExporter()
        {
            // Setup
            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>());
            var context           = new AssemblyResultsContext(assessmentSection);

            const string filePath = "test";

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

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

                // Assert
                Assert.IsInstanceOf <AssemblyExporter>(fileExporter);
            }
        }
        public void CreateFileExporter_WithContext_ReturnFileExporter()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();

            var context = new WaterLevelCalculationsForNormTargetProbabilitiesGroupContext(
                new ObservableList <HydraulicBoundaryLocation>(), assessmentSection);

            const string filePath = "test";

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

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

                // Assert
                Assert.IsInstanceOf <HydraulicBoundaryLocationCalculationsForTargetProbabilitiesExporter>(fileExporter);
            }
        }
예제 #15
0
        public void CreateFileExporter_Always_ReturnFileExporter()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var          context  = new ReferenceLineContext(new ReferenceLine(), assessmentSection);
            const string filePath = "test";

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

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

                // Assert
                Assert.IsInstanceOf <ReferenceLineExporter>(fileExporter);
            }

            mocks.VerifyAll();
        }
예제 #16
0
        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);
        }