Exemple #1
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();
        }
Exemple #2
0
            public bool TryGetFileLocation(IFileExporter exporter, out string filePath)
            {
                if (exporter is null)
                {
                    throw new ArgumentNullException(nameof(exporter));
                }

                var saveFileDialog = new SaveFileDialog
                {
                    AddExtension = true,
                    FileName     = exporter.DefaultFileName,
                    DefaultExt   = exporter.ExportFileExtension,
                    Filter       = $"{exporter.FileTypeDescription} ({exporter.ExportFileExtension})|*{exporter.ExportFileExtension}"
                };
                var dialogResult = saveFileDialog.ShowDialog(owner);

                if (dialogResult.HasValue && dialogResult.Value)
                {
                    filePath = saveFileDialog.FileName;
                    return(true);
                }

                filePath = string.Empty;
                return(false);
            }
Exemple #3
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);
                }
            }
        }
 public FileManager(IFileSystemWatcher fileSystemWatcher, IFilesAnalyzer filesAnalyzer, IFileExporter filesExporter)
 {
     _fileSystemWatcher = fileSystemWatcher;
     _filesAnalyzer     = filesAnalyzer;
     _filesExporter     = filesExporter;
     _filesCollections  = new ConcurrentDictionary <string, IList <IFile> >();
 }
        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();
        }
Exemple #6
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);
            }
        }
Exemple #7
0
 public TransactionRepository(ApplicationDbContext context, IConfiguration configuration, IFileExporter fileExporter, IMapper mapper)
 {
     _context       = context;
     _configuration = configuration;
     _fileExporter  = fileExporter;
     _mapper        = mapper;
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FileIOExportFileInteractor" /> class.
 /// </summary>
 /// <param name="fileExporter">The file exporter.</param>
 /// <param name="contestRepository">The contest repository.</param>
 /// <param name="flightMatrixRepository">The flight matrix repository.</param>
 /// <param name="pilotRepository">The pilot repository.</param>
 /// <param name="pilotRegistrationRepository">The pilot registration repository.</param>
 /// <param name="scoringRepository">The scoring repository.</param>
 /// <param name="logger">The logger.</param>
 /// <exception cref="ArgumentNullException">fileExporter</exception>
 /// <exception cref="System.ArgumentNullException">fileExporter</exception>
 public FileIOExportFileInteractor(IFileExporter fileExporter,
                                   IContestRepository contestRepository,
                                   IFlightMatrixRepository flightMatrixRepository,
                                   IPilotRepository pilotRepository,
                                   IPilotRegistrationRepository pilotRegistrationRepository,
                                   IScoringRepository scoringRepository,
                                   ILoggingService logger) : base(logger)
 {
     this.fileExporter                = fileExporter ?? throw new ArgumentNullException($"{nameof(fileExporter)} cannot be null.");
     this.contestRepository           = contestRepository ?? throw new ArgumentNullException($"{nameof(contestRepository)} cannot be null.");
     this.flightMatrixRepository      = flightMatrixRepository ?? throw new ArgumentNullException($"{nameof(flightMatrixRepository)} cannot be null.");
     this.pilotRepository             = pilotRepository ?? throw new ArgumentNullException($"{nameof(pilotRepository)} cannot be null.");
     this.pilotRegistrationRepository = pilotRegistrationRepository ?? throw new ArgumentNullException($"{nameof(pilotRegistrationRepository)} cannot be null.");
     this.scoringRepository           = scoringRepository ?? throw new ArgumentNullException($"{nameof(scoringRepository)} cannot be null.");
 }
        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);
        }
        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);
        }
Exemple #11
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);
        }
Exemple #12
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);
        }
Exemple #13
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);
        }
Exemple #16
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);
            }
        }
Exemple #18
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();
        }
 protected Generator(IFileExporter <T> fileExporter, IOperationsProvider operationsProvider)
 {
     FileExporter       = fileExporter;
     OperationsProvider = operationsProvider;
 }
 public PoliciesGenerator(IFileExporter <TResult> fileExporter, IBuildersFactory <TOperationPolicy> buildersFactory, IOperationsProvider operationsProvider) : base(fileExporter, operationsProvider)
 {
     _buildersFactory = buildersFactory;
 }
Exemple #21
0
 public GetExcelFileCommand(IFileExporter fileExporter)
 {
     _fileExporter = fileExporter;
 }
Exemple #22
0
 public SearchController(IMediator mediator, IFileExporter fileExporter)
 {
     _mediator     = mediator;
     _fileExporter = fileExporter;
 }