public void ForeColor_CollectionWithSoilModels_ReturnsControlText() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); failureMechanism.StochasticSoilModels.AddRange(new[] { PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, "path"); var stochasticSoilModelCollectionContext = new PipingStochasticSoilModelCollectionContext( failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call Color foreColor = info.ForeColor(stochasticSoilModelCollectionContext); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), foreColor); }
public void ChildNodeObjects_Always_ReturnsChildrenOfData() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("Name", new[] { new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile()), new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) }); var failureMechanism = new PipingFailureMechanism(); var stochasticSoilModelCollectionContext = new PipingStochasticSoilModelCollectionContext( failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); failureMechanism.StochasticSoilModels.AddRange(new[] { stochasticSoilModel }, "path"); // Call object[] objects = info.ChildNodeObjects(stochasticSoilModelCollectionContext); // Assert CollectionAssert.AreEqual(new[] { stochasticSoilModel }, objects); }
public void VerifyUpdates_CalculationWithoutOutputs_ReturnsTrue() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); plugin.Gui = gui; var failureMechanism = new PipingFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new SemiProbabilisticPipingCalculationScenario()); var stochasticSoilModelCollection = new PipingStochasticSoilModelCollection(); var context = new PipingStochasticSoilModelCollectionContext(stochasticSoilModelCollection, failureMechanism, assessmentSection); // Call bool updatesVerified = importInfo.VerifyUpdates(context); // Assert Assert.IsTrue(updatesVerified); mocks.VerifyAll(); }
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 PipingStochasticSoilModelCollection(); stochasticSoilModelCollection.AddRange(new[] { PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }, expectedFilePath); var failureMechanism = new PipingFailureMechanism(); var context = new PipingStochasticSoilModelCollectionContext(stochasticSoilModelCollection, failureMechanism, assessmentSection); // Call string currentPath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(expectedFilePath, currentPath); mocks.VerifyAll(); }
public void VerifyUpdates_CalculationWithOutputs_AlwaysReturnsExpectedInquiryMessage(bool isActionConfirmed) { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); plugin.Gui = gui; var failureMechanism = new PipingFailureMechanism(); var calculationWithOutput = new SemiProbabilisticPipingCalculationScenario { Output = PipingTestDataGenerator.GetRandomSemiProbabilisticPipingOutput() }; failureMechanism.CalculationsGroup.Children.Add(calculationWithOutput); var stochasticSoilModelCollection = new PipingStochasticSoilModelCollection(); var context = new PipingStochasticSoilModelCollectionContext(stochasticSoilModelCollection, failureMechanism, assessmentSection); string textBoxMessage = null; DialogBoxHandler = (name, wnd) => { var helper = new MessageBoxTester(wnd); textBoxMessage = helper.Text; if (isActionConfirmed) { helper.ClickOk(); } else { helper.ClickCancel(); } }; // Call bool updatesVerified = importInfo.VerifyUpdates(context); // Assert string expectedInquiryMessage = "Als u stochastische ondergrondmodellen importeert, " + "dan worden alle rekenresultaten van dit faalmechanisme verwijderd." + $"{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?"; Assert.AreEqual(expectedInquiryMessage, textBoxMessage); Assert.AreEqual(isActionConfirmed, updatesVerified); mocks.VerifyAll(); }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); var importTarget = new PipingStochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call IFileImporter importer = importInfo.CreateFileImporter(importTarget, ""); // Assert Assert.IsInstanceOf <StochasticSoilModelImporter <PipingStochasticSoilModel> >(importer); mocks.VerifyAll(); }
public void ParameteredConstructor_DefaultValues() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); // Call var context = new PipingStochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Assert Assert.IsInstanceOf <ObservableWrappedObjectContextBase <PipingStochasticSoilModelCollection> >(context); Assert.AreSame(failureMechanism.StochasticSoilModels, context.WrappedData); Assert.AreSame(failureMechanism, context.FailureMechanism); Assert.AreSame(assessmentSection, context.AssessmentSection); mocks.VerifyAll(); }
public void Image_Always_ReturnsSetImage() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); var stochasticSoilModelCollectionContext = new PipingStochasticSoilModelCollectionContext( failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call Image image = info.Image(stochasticSoilModelCollectionContext); // Assert TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GeneralFolderIcon, image); }
public void Text_Always_ReturnsTextFromResource() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); var stochasticSoilModelCollectionContext = new PipingStochasticSoilModelCollectionContext( failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call string text = info.Text(stochasticSoilModelCollectionContext); // Assert Assert.AreEqual("Stochastische ondergrondmodellen", text); }
public void ForeColor_CollectionWithoutSoilModels_ReturnsGrayText() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); var stochasticSoilModelCollectionContext = new PipingStochasticSoilModelCollectionContext( failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call Color foreColor = info.ForeColor(stochasticSoilModelCollectionContext); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), foreColor); }
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 PipingFailureMechanism(); var context = new PipingStochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call bool isEnabled = importInfo.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 PipingFailureMechanism(); var stochasticSoilModel = new PipingStochasticSoilModelCollection(); var context = new PipingStochasticSoilModelCollectionContext(stochasticSoilModel, failureMechanism, assessmentSection); // Call bool isEnabled = updateInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); mocks.VerifyAll(); }
public void ContextMenuStrip_Always_CallsBuilder() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); var menuBuilder = mocks.StrictMock <IContextMenuBuilder>(); using (mocks.Ordered()) { menuBuilder.Expect(mb => mb.AddImportItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddUpdateItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); } using (var treeViewControl = new TreeViewControl()) { var context = new PipingStochasticSoilModelCollectionContext( new PipingStochasticSoilModelCollection(), new PipingFailureMechanism(), assessmentSection); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); plugin.Gui = gui; // Call info.ContextMenuStrip(context, null, treeViewControl); } // Assert // Assert expectancies are called in TearDown() }
public void CreateInstance_WithContext_NewPropertiesWithInputContextAsData() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); var collection = new PipingStochasticSoilModelCollection(); var context = new PipingStochasticSoilModelCollectionContext(collection, failureMechanism, assessmentSection); // Call IObjectProperties objectProperties = info.CreateInstance(context); // Assert Assert.IsInstanceOf <PipingStochasticSoilModelCollectionProperties>(objectProperties); Assert.AreSame(collection, objectProperties.Data); mocks.VerifyAll(); }
public void IsEnabled_SoilModelCollectionSourcePathSet_ReturnTrue() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); var stochasticSoilModel = new PipingStochasticSoilModelCollection(); stochasticSoilModel.AddRange(Enumerable.Empty <PipingStochasticSoilModel>(), "some/path"); var context = new PipingStochasticSoilModelCollectionContext(stochasticSoilModel, failureMechanism, assessmentSection); // Call bool isEnabled = updateInfo.IsEnabled(context); // Assert Assert.IsTrue(isEnabled); mocks.VerifyAll(); }