public void CurrentPath_StochasticSoilModelCollectionHasPathSet_ReturnsExpectedPath() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); const string expectedFilePath = "some/path"; var stochasticSoilModelCollection = new MacroStabilityInwardsStochasticSoilModelCollection(); stochasticSoilModelCollection.AddRange(new[] { MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel() }, expectedFilePath); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var context = new MacroStabilityInwardsStochasticSoilModelCollectionContext(stochasticSoilModelCollection, failureMechanism, assessmentSection); // Call string currentPath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(expectedFilePath, currentPath); mocks.VerifyAll(); }
public void CurrentPath_FailureMechanismSectionsSourcePathSet_ReturnsExpectedPath() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); string sourcePath = TestHelper.GetScratchPadPath(); failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), sourcePath); var context = new WaterPressureAsphaltCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new RiskeerPlugin()) { UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call string currentFilePath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(sourcePath, currentFilePath); mocks.VerifyAll(); } }
public void CurrentPath_DikeProfileCollectionHasPathSet_ReturnsExpectedPath() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); const string expectedFilePath = "some/path"; var surfaceLines = new DikeProfileCollection(); surfaceLines.AddRange(new[] { DikeProfileTestFactory.CreateDikeProfile() }, expectedFilePath); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var context = new DikeProfilesContext(surfaceLines, failureMechanism, assessmentSection); using (var plugin = new GrassCoverErosionInwardsPlugin()) { UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call string currentFilePath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(expectedFilePath, currentFilePath); mocks.VerifyAll(); } }
private void UpdateItemsUsingDialog(UpdateInfo updateInfo, object target) { string oldPath = updateInfo.CurrentPath(target); string filePath = oldPath; if (!File.Exists(filePath)) { filePath = inquiryHelper.GetSourceFileLocation(updateInfo.FileFilterGenerator.Filter); } if (filePath != null && updateInfo.VerifyUpdates(target)) { RunUpdateActivity(updateInfo.CreateFileImporter(target, filePath), updateInfo.Name); } else { if (!string.IsNullOrEmpty(oldPath)) { log.InfoFormat(Resources.GuiUpdateHandler_UpdateItemsUsingDialog_Updating_from_Path_0_cancelled, oldPath); } else { log.InfoFormat(Resources.GuiUpdateHandler_UpdateItemsUsingDialog_Updating_cancelled); } } }
public void CurrentPath_FailureMechanismSectionsSourcePathSet_ReturnsExpectedPath() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); string sourcePath = TestHelper.GetScratchPadPath(); failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), sourcePath); var context = new PipingFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new PipingPlugin()) { plugin.Gui = gui; UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call string currentFilePath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(sourcePath, currentFilePath); } mocks.VerifyAll(); }
public void CurrentPath_SurfaceLineCollectionHasPathSet_ReturnsExpectedPath() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); const string expectedFilePath = "some/path"; var surfaceLines = new MacroStabilityInwardsSurfaceLineCollection(); surfaceLines.AddRange(new[] { new MacroStabilityInwardsSurfaceLine(string.Empty) }, expectedFilePath); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var context = new MacroStabilityInwardsSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection); // Call string currentPath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(expectedFilePath, currentPath); mocks.VerifyAll(); }
public void CurrentPath_FailureMechanismSectionsHasPathSet_ReturnsExpectedPath() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); const string expectedFilePath = "path"; var failureMechanism = new SpecificFailureMechanism(); failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), expectedFilePath); var context = new SpecificFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new RiskeerPlugin()) { UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call string currentFilePath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(expectedFilePath, currentFilePath); mocks.VerifyAll(); } }
public void CurrentPath_ForeshoreProfileCollectionHasPathSet_ReturnsExpectedPath() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); var failureMechanism = mocks.Stub <ICalculatableFailureMechanism>(); mocks.ReplayAll(); const string expectedFilePath = "some/path"; var foreshoreProfiles = new ForeshoreProfileCollection(); foreshoreProfiles.AddRange(new[] { new TestForeshoreProfile() }, expectedFilePath); var context = new ForeshoreProfilesContext(foreshoreProfiles, failureMechanism, assessmentSection); using (var plugin = new RiskeerPlugin()) { UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call string currentFilePath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(expectedFilePath, currentFilePath); mocks.VerifyAll(); } }
public void ImplicitOperator_OptionalDelegatesAndPropertiesSet_UpdateInfoFullyConverted() { // Setup var mocks = new MockRepository(); var fileUpdateer = mocks.StrictMock <IFileImporter>(); mocks.ReplayAll(); const string name = "name"; const string category = "category"; const string path = "somePath"; var image = new Bitmap(16, 16); var generator = new FileFilterGenerator(); var info = new UpdateInfo <int> { CreateFileImporter = (data, filePath) => fileUpdateer, IsEnabled = data => false, Name = name, Category = category, Image = image, FileFilterGenerator = generator, VerifyUpdates = i => true, CurrentPath = i => path }; // Precondition Assert.IsInstanceOf <UpdateInfo <int> >(info); // Call UpdateInfo convertedInfo = info; // Assert Assert.IsInstanceOf <UpdateInfo>(convertedInfo); Assert.AreEqual(typeof(int), convertedInfo.DataType); Assert.IsNotNull(convertedInfo.CreateFileImporter); Assert.AreSame(fileUpdateer, convertedInfo.CreateFileImporter(12, "")); Assert.IsNotNull(convertedInfo.IsEnabled); Assert.IsFalse(convertedInfo.IsEnabled(12)); Assert.AreEqual(name, info.Name); Assert.AreEqual(category, info.Category); Assert.AreSame(image, info.Image); Assert.AreEqual(generator, info.FileFilterGenerator); Assert.IsNotNull(convertedInfo.VerifyUpdates); Assert.IsTrue(convertedInfo.VerifyUpdates(12)); Assert.IsNotNull(convertedInfo.CurrentPath); Assert.AreEqual(path, convertedInfo.CurrentPath(12)); mocks.VerifyAll(); }
public void CreateFailureMechanismSectionsUpdateInfo_WithoutSourcePath_ReturnsNullPath() { // Setup var mocks = new MockRepository(); var sectionResultUpdateStrategy = mocks.Stub <IFailureMechanismSectionResultUpdateStrategy <FailureMechanismSectionResult> >(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); // Call UpdateInfo <FailureMechanismSectionsContext> updateInfo = RiskeerUpdateInfoFactory.CreateFailureMechanismSectionsUpdateInfo < FailureMechanismSectionsContext, TestFailureMechanism, FailureMechanismSectionResult>(sectionResultUpdateStrategy); // Assert var failureMechanismSectionsContext = new FailureMechanismSectionsContext(new TestFailureMechanism(), assessmentSection); Assert.IsNull(updateInfo.CurrentPath(failureMechanismSectionsContext)); mocks.VerifyAll(); }
public void CurrentPath_StructureCollectionHasPathSet_ReturnsExpectedPath() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); const string expectedFilePath = "some/path"; var structures = new StructureCollection <HeightStructure>(); structures.AddRange(Enumerable.Empty <HeightStructure>(), expectedFilePath); var failureMechanism = new HeightStructuresFailureMechanism(); var context = new HeightStructuresContext(structures, failureMechanism, assessmentSection); // Call string currentPath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(expectedFilePath, currentPath); mocks.VerifyAll(); }
public void CreateFailureMechanismSectionsUpdateInfo_WithSourcePath_ReturnsSourcePath() { // Setup var mocks = new MockRepository(); var sectionResultUpdateStrategy = mocks.Stub <IFailureMechanismSectionResultUpdateStrategy <FailureMechanismSectionResult> >(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); // Call UpdateInfo <FailureMechanismSectionsContext> updateInfo = RiskeerUpdateInfoFactory.CreateFailureMechanismSectionsUpdateInfo < FailureMechanismSectionsContext, TestFailureMechanism, FailureMechanismSectionResult>(sectionResultUpdateStrategy); // Assert var testFailureMechanism = new TestFailureMechanism(); testFailureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), "path/to/sections"); var failureMechanismSectionsContext = new FailureMechanismSectionsContext(testFailureMechanism, assessmentSection); Assert.AreEqual(testFailureMechanism.FailureMechanismSectionSourcePath, updateInfo.CurrentPath(failureMechanismSectionsContext)); mocks.VerifyAll(); }