Beispiel #1
0
        public void CreateCalculationGroupConfigurationExportInfo_WithArguments_ExpectedPropertiesSet()
        {
            // Setup
            var mocks         = new MockRepository();
            var fileImporter  = mocks.Stub <IFileExporter>();
            var inquiryHelper = mocks.Stub <IInquiryHelper>();

            mocks.ReplayAll();

            Func <ICalculationContext <CalculationGroup, ICalculatableFailureMechanism>, bool> isEnabled = context => false;
            Func <ICalculationContext <CalculationGroup, ICalculatableFailureMechanism>, string, IFileExporter> createFileExporter = (context, s) => fileImporter;

            // Call
            ExportInfo <ICalculationContext <CalculationGroup, ICalculatableFailureMechanism> > exportInfo =
                RiskeerExportInfoFactory.CreateCalculationGroupConfigurationExportInfo(createFileExporter, isEnabled, inquiryHelper);

            // Assert
            Assert.AreSame(isEnabled, exportInfo.IsEnabled);
            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.IsNotNull(exportInfo.GetExportPath);

            mocks.VerifyAll();
        }
Beispiel #2
0
        public override IEnumerable <ExportInfo> GetExportInfos()
        {
            yield return(RiskeerExportInfoFactory.CreateCalculationGroupConfigurationExportInfo <ClosingStructuresCalculationGroupContext>(
                             (context, filePath) => new ClosingStructuresCalculationConfigurationExporter(context.WrappedData.Children, filePath),
                             context => context.WrappedData.Children.Any(),
                             GetInquiryHelper()));

            yield return(RiskeerExportInfoFactory.CreateCalculationConfigurationExportInfo <ClosingStructuresCalculationScenarioContext>(
                             (context, filePath) => new ClosingStructuresCalculationConfigurationExporter(new[]
            {
                context.WrappedData
            }, filePath),
                             GetInquiryHelper()));
        }
Beispiel #3
0
        public override IEnumerable <ExportInfo> GetExportInfos()
        {
            yield return(new ExportInfo <GrassCoverErosionOutwardsCalculationGroupContext>
            {
                Name = context => RiskeerCommonFormsResources.WaveConditionsExporter_DisplayName,
                Extension = RiskeerCommonFormsResources.DataTypeDisplayName_csv_file_filter_Extension,
                CreateFileExporter = (context, filePath) =>
                {
                    IEnumerable <GrassCoverErosionOutwardsWaveConditionsCalculation> calculations = context.WrappedData.GetCalculations().Cast <GrassCoverErosionOutwardsWaveConditionsCalculation>();
                    return new GrassCoverErosionOutwardsWaveConditionsExporter(calculations, filePath, input => WaveConditionsInputHelper.GetTargetProbability(input, context.AssessmentSection)
                                                                               .ToString(CultureInfo.InvariantCulture));
                },
                IsEnabled = context => context.WrappedData.GetCalculations().Any(c => c.HasOutput),
                GetExportPath = () => ExportHelper.GetFilePath(GetInquiryHelper(), new FileFilterGenerator(RiskeerCommonFormsResources.DataTypeDisplayName_csv_file_filter_Extension,
                                                                                                           RiskeerCommonFormsResources.DataTypeDisplayName_csv_file_filter_Description))
            });

            yield return(new ExportInfo <GrassCoverErosionOutwardsWaveConditionsCalculationContext>
            {
                Name = context => RiskeerCommonFormsResources.WaveConditionsExporter_DisplayName,
                Extension = RiskeerCommonFormsResources.DataTypeDisplayName_csv_file_filter_Extension,
                CreateFileExporter = (context, filePath) => new GrassCoverErosionOutwardsWaveConditionsExporter(new[]
                {
                    context.WrappedData
                }, filePath,
                                                                                                                input =>
                                                                                                                WaveConditionsInputHelper.GetTargetProbability(input, context.AssessmentSection)
                                                                                                                .ToString(CultureInfo.InvariantCulture)),
                IsEnabled = context => context.WrappedData.HasOutput,
                GetExportPath = () => ExportHelper.GetFilePath(GetInquiryHelper(), new FileFilterGenerator(RiskeerCommonFormsResources.DataTypeDisplayName_csv_file_filter_Extension,
                                                                                                           RiskeerCommonFormsResources.DataTypeDisplayName_csv_file_filter_Description))
            });

            yield return(RiskeerExportInfoFactory.CreateCalculationGroupConfigurationExportInfo <GrassCoverErosionOutwardsCalculationGroupContext>(
                             (context, filePath) => new GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationExporter(
                                 context.WrappedData.Children, filePath, context.AssessmentSection),
                             context => context.WrappedData.Children.Any(),
                             GetInquiryHelper()));

            yield return(RiskeerExportInfoFactory.CreateCalculationConfigurationExportInfo <GrassCoverErosionOutwardsWaveConditionsCalculationContext>(
                             (context, filePath) => new GrassCoverErosionOutwardsWaveConditionsCalculationConfigurationExporter(
                                 new[]
            {
                context.WrappedData
            }, filePath, context.AssessmentSection),
                             GetInquiryHelper()));
        }