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 MacroStabilityInwardsFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new MacroStabilityInwardsCalculationScenario()); var stochasticSoilModelCollection = new MacroStabilityInwardsStochasticSoilModelCollection(); var context = new MacroStabilityInwardsStochasticSoilModelCollectionContext(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 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 ForeColor_CollectionWithSoilProfiles_ReturnsControlText() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); failureMechanism.StochasticSoilModels.AddRange(new[] { MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel() }, "path"); var stochasticSoilModelCollectionContext = new MacroStabilityInwardsStochasticSoilModelCollectionContext( failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call Color foreColor = info.ForeColor(stochasticSoilModelCollectionContext); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), foreColor); }
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 MacroStabilityInwardsFailureMechanism(); var calculationWithOutput = new MacroStabilityInwardsCalculationScenario { Output = MacroStabilityInwardsOutputTestFactory.CreateOutput() }; failureMechanism.CalculationsGroup.Children.Add(calculationWithOutput); var stochasticSoilModelCollection = new MacroStabilityInwardsStochasticSoilModelCollection(); var context = new MacroStabilityInwardsStochasticSoilModelCollectionContext(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 ChildNodeObjects_Always_ReturnsChildrenOfData() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var soilProfile1 = new MacroStabilityInwardsSoilProfile1D("soilProfile1", 0, new List <MacroStabilityInwardsSoilLayer1D> { new MacroStabilityInwardsSoilLayer1D(10) }); var soilProfile2 = new MacroStabilityInwardsSoilProfile1D("soilProfile2", 0, new List <MacroStabilityInwardsSoilLayer1D> { new MacroStabilityInwardsSoilLayer1D(10) }); var stochasticSoilProfile1 = new MacroStabilityInwardsStochasticSoilProfile(1.0, soilProfile1); var stochasticSoilProfile2 = new MacroStabilityInwardsStochasticSoilProfile(1.0, soilProfile2); MacroStabilityInwardsStochasticSoilModel stochasticSoilModel = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel(new[] { stochasticSoilProfile1, stochasticSoilProfile2 }); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var stochasticSoilModelCollectionContext = new MacroStabilityInwardsStochasticSoilModelCollectionContext( failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); failureMechanism.StochasticSoilModels.AddRange(new[] { stochasticSoilModel }, "path"); // Call object[] objects = info.ChildNodeObjects(stochasticSoilModelCollectionContext); // Assert CollectionAssert.AreEqual(new[] { stochasticSoilModel }, objects); }
public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var importTarget = new MacroStabilityInwardsStochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call IFileImporter importer = importInfo.CreateFileImporter(importTarget, ""); // Assert Assert.IsInstanceOf <StochasticSoilModelImporter <MacroStabilityInwardsStochasticSoilModel> >(importer); 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_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 ParameteredConstructor_DefaultValues() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); // Call var context = new MacroStabilityInwardsStochasticSoilModelCollectionContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Assert Assert.IsInstanceOf <ObservableWrappedObjectContextBase <MacroStabilityInwardsStochasticSoilModelCollection> >(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 MacroStabilityInwardsFailureMechanism(); var stochasticSoilModelCollectionContext = new MacroStabilityInwardsStochasticSoilModelCollectionContext( 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 MacroStabilityInwardsFailureMechanism(); var stochasticSoilModelCollectionContext = new MacroStabilityInwardsStochasticSoilModelCollectionContext( failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call string text = info.Text(stochasticSoilModelCollectionContext); // Assert Assert.AreEqual("Stochastische ondergrondmodellen", text); }
public void ForeColor_CollectionWithoutSoilProfiles_ReturnsGrayText() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var stochasticSoilModelCollectionContext = new MacroStabilityInwardsStochasticSoilModelCollectionContext( failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); // Call Color foreColor = info.ForeColor(stochasticSoilModelCollectionContext); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), foreColor); }
public void IsEnabled_SoilModelCollectionSourcePathSet_ReturnTrue() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var stochasticSoilModel = new MacroStabilityInwardsStochasticSoilModelCollection(); stochasticSoilModel.AddRange(Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(), "some/path"); var context = new MacroStabilityInwardsStochasticSoilModelCollectionContext(stochasticSoilModel, failureMechanism, assessmentSection); // Call bool isEnabled = updateInfo.IsEnabled(context); // Assert Assert.IsTrue(isEnabled); mocks.VerifyAll(); }
public void CreateInstance_WithContext_NewPropertiesWithInputContextAsData() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var collection = new MacroStabilityInwardsStochasticSoilModelCollection(); var context = new MacroStabilityInwardsStochasticSoilModelCollectionContext(collection, failureMechanism, assessmentSection); // Call IObjectProperties objectProperties = info.CreateInstance(context); // Assert Assert.IsInstanceOf <MacroStabilityInwardsStochasticSoilModelCollectionProperties>(objectProperties); Assert.AreSame(collection, objectProperties.Data); 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 MacroStabilityInwardsStochasticSoilModelCollectionContext( new MacroStabilityInwardsStochasticSoilModelCollection(), new MacroStabilityInwardsFailureMechanism(), 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() }