public void CreateCalculationConfigurationImportInfo_WithArguments_ExpectedPropertiesSet() { // Setup var mocks = new MockRepository(); var fileImporter = mocks.Stub <IFileImporter>(); mocks.ReplayAll(); Func <ICalculationContext <CalculationGroup, ICalculatableFailureMechanism>, string, IFileImporter> createFileImporter = (context, s) => fileImporter; // Call ImportInfo <ICalculationContext <CalculationGroup, ICalculatableFailureMechanism> > importInfo = RiskeerImportInfoFactory.CreateCalculationConfigurationImportInfo(createFileImporter); // Assert Assert.AreSame(createFileImporter, importInfo.CreateFileImporter); Assert.AreEqual("Riskeer berekeningenconfiguratie", importInfo.Name); Assert.AreEqual("Algemeen", importInfo.Category); FileFilterGenerator fileFilterGenerator = importInfo.FileFilterGenerator; Assert.AreEqual("Riskeer berekeningenconfiguratie (*.xml)|*.xml", fileFilterGenerator.Filter); TestHelper.AssertImagesAreEqual(Resources.GeneralFolderIcon, importInfo.Image); Assert.IsTrue(importInfo.IsEnabled(null)); mocks.VerifyAll(); }
public void IsEnabled_ReferenceLineWithoutGeometry_ReturnFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); var context = new HeightStructuresContext(failureMechanism.HeightStructures, failureMechanism, assessmentSection); using (var plugin = new HeightStructuresPlugin()) { ImportInfo importInfo = GetImportInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); } mocks.VerifyAll(); }
public void IsEnabled_ReferenceLineWithGeometry_ReturnTrue() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(ReferenceLineTestFactory.CreateReferenceLineWithGeometry()); mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var context = new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection); using (var plugin = new GrassCoverErosionInwardsPlugin()) { ImportInfo importInfo = GetImportInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsTrue(isEnabled); } mocks.VerifyAll(); }
public void IsEnabled_Always_ReturnTrue() { // Call bool isEnabled = importInfo.IsEnabled(null); // Assert Assert.IsTrue(isEnabled); }
public void IsEnabled_ReferenceLineWithoutGeometry_ReturnFalse() { // Setup var mocks = new MockRepository(); var failureMechanism = mocks.Stub <IFailureMechanism <FailureMechanismSectionResult> >(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var context = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); mocks.VerifyAll(); }
public void IsEnabled_ReferenceLineWithoutGeometry_ReturnFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var context = new MacroStabilityInwardsStochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); mocks.VerifyAll(); }
public void IsEnabled_Always_ReturnsTrue() { // Setup using (var plugin = new StabilityPointStructuresPlugin()) { ImportInfo info = GetImportInfo(plugin); // Call bool isEnabled = info.IsEnabled(null); // Assert Assert.IsTrue(isEnabled); } }
public void ImplicitOperator_OptionalDelegatesAndPropertiesSet_ImportInfoFullyConverted() { // Setup var mocks = new MockRepository(); var fileImporter = mocks.StrictMock <IFileImporter>(); mocks.ReplayAll(); const string name = "name"; const string category = "category"; var image = new Bitmap(16, 16); var generator = new FileFilterGenerator(); var info = new ImportInfo <int> { CreateFileImporter = (data, filePath) => fileImporter, IsEnabled = data => false, Name = name, Category = category, Image = image, FileFilterGenerator = generator, VerifyUpdates = i => true }; // Precondition Assert.IsInstanceOf <ImportInfo <int> >(info); // Call ImportInfo convertedInfo = info; // Assert Assert.IsInstanceOf <ImportInfo>(convertedInfo); Assert.AreEqual(typeof(int), convertedInfo.DataType); Assert.IsNotNull(convertedInfo.CreateFileImporter); Assert.AreSame(fileImporter, 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(info.VerifyUpdates); Assert.IsTrue(convertedInfo.VerifyUpdates(12)); mocks.VerifyAll(); }
public void IsEnabled_ReferenceLineWithGeometry_ReturnTrue() { // Setup var mocks = new MockRepository(); var inquiryHelper = mocks.Stub <IInquiryHelper>(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(ReferenceLineTestFactory.CreateReferenceLineWithGeometry()); mocks.ReplayAll(); var context = new PipingFailureMechanismSectionsContext(new PipingFailureMechanism(), assessmentSection); ImportInfo <PipingFailureMechanismSectionsContext> importInfo = GetImportInfo(inquiryHelper); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsTrue(isEnabled); mocks.VerifyAll(); }
public void ImplicitOperator_NoneOfTheOptionalDelegatesAndPropertiesSet_ImportInfoFullyConverted() { // Setup var info = new ImportInfo <int>(); // Precondition Assert.IsInstanceOf <ImportInfo <int> >(info); // Call ImportInfo convertedInfo = info; // Assert Assert.IsInstanceOf <ImportInfo>(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("Importeren gegevens", info.Category); TestHelper.AssertImagesAreEqual(Resources.brick, info.Image); Assert.IsNull(info.FileFilterGenerator); Assert.IsNull(info.VerifyUpdates); }