public void Cancel_WhenImportingAndUncancelable_ImportActivityStateExecuted() { // Setup var mocks = new MockRepository(); var fileImporter = mocks.Stub <IFileImporter>(); fileImporter.Stub(x => x.SetProgressChanged(null)).IgnoreArguments(); fileImporter.Stub(i => i.Import()).Return(true); mocks.ReplayAll(); var fileImportActivity = new FileImportActivity(fileImporter, ""); fileImportActivity.ProgressChanged += (sender, args) => { if (fileImportActivity.State != ActivityState.Canceled) { // Call fileImportActivity.Cancel(); } }; // Assert fileImportActivity.Run(); Assert.AreEqual(ActivityState.Executed, fileImportActivity.State); mocks.VerifyAll(); }
public void Run_FileImportActivityWithSimpleFileImporter_ProgressTextShouldBeSetAfterImporterProgressChanged() { // Setup var fileImporter = new SimpleFileImporter <object>(new object()); var fileImportActivity = new FileImportActivity(fileImporter, ""); // Call fileImportActivity.Run(); // Reuse the activity // Assert Assert.AreEqual("Stap 1 van 10 | Step description", fileImportActivity.ProgressText); }
/// <summary> /// Imports the <see cref="MacroStabilityInwardsStochasticSoilModel"/> data for the <see cref="MacroStabilityInwardsFailureMechanism"/> /// of the given <see cref="IAssessmentSection"/>. /// </summary> /// <param name="assessmentSection">The <see cref="AssessmentSection"/> to import on.</param> /// <remarks>This will import 4 soil models with one profile each.</remarks> public static void ImportMacroStabilityInwardsStochasticSoilModels(AssessmentSection assessmentSection) { using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DataImportHelper).Assembly, true, "DR6.soil")) { string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6.soil"); var activity = new FileImportActivity(new StochasticSoilModelImporter <MacroStabilityInwardsStochasticSoilModel>( assessmentSection.MacroStabilityInwards.StochasticSoilModels, filePath, new ImportMessageProvider(), MacroStabilityInwardsStochasticSoilModelImporterConfigurationFactory.CreateReplaceStrategyConfiguration(assessmentSection.MacroStabilityInwards)), "MacroStabilityInwardsStochasticSoilModelImporter"); activity.Run(); activity.Finish(); } }
/// <summary> /// Imports the <see cref="MacroStabilityInwardsSurfaceLine"/> data for the <see cref="MacroStabilityInwardsFailureMechanism"/> /// of the given <see cref="IAssessmentSection"/>. /// </summary> /// <param name="assessmentSection">The <see cref="AssessmentSection"/> to import on.</param> /// <remarks>This will import 4 surface lines.</remarks> public static void ImportMacroStabilityInwardsSurfaceLines(AssessmentSection assessmentSection) { using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DataImportHelper).Assembly, true, "DR6_surfacelines.csv", "DR6_surfacelines.krp.csv")) { string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6_surfacelines.csv"); var activity = new FileImportActivity(new SurfaceLinesCsvImporter <MacroStabilityInwardsSurfaceLine>( assessmentSection.MacroStabilityInwards.SurfaceLines, filePath, new ImportMessageProvider(), MacroStabilityInwardsSurfaceLinesCsvImporterConfigurationFactory.CreateReplaceStrategyConfiguration(assessmentSection.MacroStabilityInwards, assessmentSection.ReferenceLine)), "MacroStabilityInwardsSurfaceLinesCsvImporter"); activity.Run(); activity.Finish(); } }
/// <summary> /// Imports the <see cref="PipingStochasticSoilModel"/> data for the <see cref="PipingFailureMechanism"/> /// of the given <see cref="IAssessmentSection"/> and updates existing data based upon the imported /// data. /// </summary> /// <param name="assessmentSection">The <see cref="AssessmentSection"/> to import on.</param> /// <remarks>When data from <see cref="DataImportHelper.ImportPipingStochasticSoilModels"/> is added first, /// then calling this method will remove soil model 'PK001_0004_Piping', stochastic soil profile 'W1-6_4_1D1' /// and update the probability of stochastic soil profile '6-3_22' (100% to 50%).</remarks> public static void UpdatePipingStochasticSoilModels(AssessmentSection assessmentSection) { using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DataUpdateHelper).Assembly, true, "DR6_updated.soil")) { string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6_updated.soil"); var activity = new FileImportActivity( new StochasticSoilModelImporter <PipingStochasticSoilModel>( assessmentSection.Piping.StochasticSoilModels, filePath, new UpdateMessageProvider(), PipingStochasticSoilModelImporterConfigurationFactory.CreateUpdateStrategyConfiguration(assessmentSection.Piping)), "StochasticSoilModelUpdater"); activity.Run(); activity.Finish(); } }
public void Run_FileImportActivityWithFileImporter_FileImporterImportCalled() { // Setup var mocks = new MockRepository(); var fileImporter = mocks.Stub <IFileImporter>(); fileImporter.Stub(x => x.SetProgressChanged(null)).IgnoreArguments(); fileImporter.Expect(i => i.Import()).Return(true); mocks.ReplayAll(); var fileImportActivity = new FileImportActivity(fileImporter, ""); // Call fileImportActivity.Run(); // Assert mocks.VerifyAll(); }
/// <summary> /// Imports <see cref="FailureMechanismSection"/> data for a given <see cref="IFailureMechanism{T}"/>. /// </summary> /// <param name="assessmentSection">The <see cref="AssessmentSection"/> that contains the <see cref="IFailureMechanism{T}"/> instance.</param> /// <param name="failureMechanism">The <see cref="IFailureMechanism{T}"/> instance to import on.</param> /// <remarks> /// <para>This will import 283 failure mechanism sections.</para> /// <para>Imports using <see cref="FileImportActivity"/>.</para> /// </remarks> public static void ImportFailureMechanismSections(AssessmentSection assessmentSection, IFailureMechanism <FailureMechanismSectionResult> failureMechanism) { using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DataImportHelper).Assembly, true, "traject_6-3_vakken.shp", "traject_6-3_vakken.dbf", "traject_6-3_vakken.prj", "traject_6-3_vakken.shx")) { string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3_vakken.shp"); var activity = new FileImportActivity(new FailureMechanismSectionsImporter( failureMechanism, assessmentSection.ReferenceLine, filePath, new FailureMechanismSectionReplaceStrategy(failureMechanism), new ImportMessageProvider()), "FailureMechanismSectionsImporter"); activity.Run(); activity.Finish(); } }
public void Cancel_WhenImportingAndCancelable_ImportActivityStateCanceled() { // Setup var fileImporter = new SimpleFileImporter <object>(new object()); var fileImportActivity = new FileImportActivity(fileImporter, ""); fileImportActivity.ProgressChanged += (sender, args) => { if (fileImportActivity.State != ActivityState.Canceled) { // Call fileImportActivity.Cancel(); } }; // Assert fileImportActivity.Run(); Assert.AreEqual(ActivityState.Canceled, fileImportActivity.State); }
public void Run_FileImportActivityWithFileImporterAndImportFails_ImportActivityStateFailed() { // Setup var mocks = new MockRepository(); var fileImporter = mocks.Stub <IFileImporter>(); fileImporter.Stub(x => x.SetProgressChanged(null)).IgnoreArguments(); fileImporter.Expect(i => i.Import()).Return(false); mocks.ReplayAll(); var fileImportActivity = new FileImportActivity(fileImporter, ""); // Call fileImportActivity.Run(); // Assert Assert.AreEqual(ActivityState.Failed, fileImportActivity.State); mocks.VerifyAll(); }
/// <summary> /// Imports the <see cref="ReferenceLine"/> on the <see cref="AssessmentSection"/>. /// </summary> /// <param name="assessmentSection">The <see cref="AssessmentSection"/> to import the reference line on.</param> public static void ImportReferenceLine(AssessmentSection assessmentSection) { using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DataImportHelper).Assembly, true, "traject_6-3.shp", "traject_6-3.dbf", "traject_6-3.prj", "traject_6-3.shx")) { string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3.shp"); var mocks = new MockRepository(); var viewCommands = mocks.Stub <IViewCommands>(); mocks.ReplayAll(); var activity = new FileImportActivity(new ReferenceLineImporter(assessmentSection.ReferenceLine, new ReferenceLineUpdateHandler(assessmentSection, viewCommands), filePath), "ReferenceLineImporter"); activity.Run(); activity.Finish(); mocks.VerifyAll(); } }