public void ImplicitOperator_NoneOfTheOptionalDelegatesAndPropertiesSet_UpdateInfoFullyConverted() { // Setup var info = new UpdateInfo <int>(); // 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.IsNull(convertedInfo.CreateFileImporter(12, "")); Assert.IsNotNull(convertedInfo.IsEnabled); Assert.IsTrue(convertedInfo.IsEnabled(12)); Assert.IsNull(info.Name); Assert.AreEqual("Bijwerken gegevens", info.Category); TestHelper.AssertImagesAreEqual(Resources.brick, info.Image); Assert.IsNull(info.FileFilterGenerator); Assert.IsNull(info.CurrentPath); Assert.IsNull(info.VerifyUpdates); }
public void IsEnabled_DikeProfileCollectionSourcePathSet_ReturnTrue() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var dikeProfiles = new DikeProfileCollection(); dikeProfiles.AddRange(Enumerable.Empty <DikeProfile>(), "some/path"); var context = new DikeProfilesContext(dikeProfiles, failureMechanism, assessmentSection); using (var plugin = new GrassCoverErosionInwardsPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsTrue(isEnabled); } mocks.VerifyAll(); }
public void IsEnabled_FailureMechanismSectionsSourcePathSet_ReturnTrue() { // 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 importInfo = GetUpdateInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsTrue(isEnabled); } mocks.VerifyAll(); }
public void IsEnabled_FailureMechanismSectionsSourcePathNull_ReturnFalse() { // 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(); var context = new PipingFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new PipingPlugin()) { plugin.Gui = gui; UpdateInfo importInfo = GetUpdateInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); } mocks.VerifyAll(); }
public void IsEnabled_DikeProfileCollectionSourcePathNull_ReturnFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var dikeProfiles = new DikeProfileCollection(); var context = new DikeProfilesContext(dikeProfiles, failureMechanism, assessmentSection); using (var plugin = new GrassCoverErosionInwardsPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); } mocks.VerifyAll(); }
public void IsEnabled_FailureMechanismSectionsSourcePathSet_ReturnTrue() { // 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 importInfo = GetUpdateInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsTrue(isEnabled); } mocks.VerifyAll(); }
public void IsEnabled_SourcePathSet_ReturnTrue() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new SpecificFailureMechanism(); failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), "path"); var context = new SpecificFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new RiskeerPlugin()) { UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call bool isEnabled = updateInfo.IsEnabled(context); // Assert Assert.IsTrue(isEnabled); } mocks.VerifyAll(); }
public void IsEnabled_SourcePathNotSet_ReturnFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); var failureMechanism = mocks.Stub <ICalculatableFailureMechanism>(); mocks.ReplayAll(); var foreshoreProfiles = new ForeshoreProfileCollection(); var context = new ForeshoreProfilesContext(foreshoreProfiles, failureMechanism, assessmentSection); using (var plugin = new RiskeerPlugin()) { UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call bool isEnabled = updateInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); } mocks.VerifyAll(); }
public void IsEnabled_SoilModelCollectionSourcePathNull_ReturnFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var stochasticSoilModel = new MacroStabilityInwardsStochasticSoilModelCollection(); var context = new MacroStabilityInwardsStochasticSoilModelCollectionContext(stochasticSoilModel, failureMechanism, assessmentSection); // Call bool isEnabled = updateInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); mocks.VerifyAll(); }
public void IsEnabled_SourcePathNull_ReturnFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); var structures = new StructureCollection <HeightStructure>(); var context = new HeightStructuresContext(structures, failureMechanism, assessmentSection); // Call bool isEnabled = updateInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); 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_ReturnsIsEnabledFalse() { // 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.IsFalse(updateInfo.IsEnabled(failureMechanismSectionsContext)); mocks.VerifyAll(); }
public void IsEnabled_FailureMechanismSectionsSourcePathNull_ReturnFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); var context = new WaterPressureAsphaltCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new RiskeerPlugin()) { UpdateInfo importInfo = GetUpdateInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); } mocks.VerifyAll(); }