public void CreateFileImporter_Always_ReturnFileImporter() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); var importTarget = new StabilityPointStructuresContext(failureMechanism.StabilityPointStructures, failureMechanism, assessmentSection); using (var plugin = new StabilityPointStructuresPlugin()) { ImportInfo importInfo = GetImportInfo(plugin); // Call IFileImporter importer = importInfo.CreateFileImporter(importTarget, "test"); // Assert Assert.IsInstanceOf <StabilityPointStructuresImporter>(importer); } mocks.VerifyAll(); }
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(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation <StabilityPointStructuresInput>()); var structures = new StructureCollection <StabilityPointStructure>(); var context = new StabilityPointStructuresContext(structures, failureMechanism, assessmentSection); using (var plugin = new StabilityPointStructuresPlugin()) { plugin.Gui = gui; ImportInfo importInfo = GetImportInfo(plugin); // Call bool updatesVerified = importInfo.VerifyUpdates(context); // Assert Assert.IsTrue(updatesVerified); mocks.VerifyAll(); } }
public void Text_Always_ReturnExpectedText() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); var context = new StabilityPointStructuresContext(failureMechanism.StabilityPointStructures, failureMechanism, assessmentSection); using (var plugin = new StabilityPointStructuresPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call string text = info.Text(context); // Assert const string expectedText = "Kunstwerken"; Assert.AreEqual(expectedText, text); } 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 StabilityPointStructuresFailureMechanism(); var context = new StabilityPointStructuresContext(failureMechanism.StabilityPointStructures, failureMechanism, assessmentSection); using (var plugin = new StabilityPointStructuresPlugin()) { ImportInfo importInfo = GetImportInfo(plugin); // Call bool isEnabled = importInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); } mocks.VerifyAll(); }
public void ForeColor_CollectionIsEmpty_ReturnGrayText() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); // Precondition CollectionAssert.IsEmpty(failureMechanism.StabilityPointStructures); var context = new StabilityPointStructuresContext(failureMechanism.StabilityPointStructures, failureMechanism, assessmentSection); using (var plugin = new StabilityPointStructuresPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call Color color = info.ForeColor(context); // Assert Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); } mocks.VerifyAll(); }
public void Image_Always_ReturnExpectedImage() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); var context = new StabilityPointStructuresContext(failureMechanism.StabilityPointStructures, failureMechanism, assessmentSection); using (var plugin = new StabilityPointStructuresPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call Image image = info.Image(context); // Assert TestHelper.AssertImagesAreEqual(RiskeerCommonFormsProperties.GeneralFolderIcon, image); } 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(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation <StabilityPointStructuresInput> { Output = new TestStructuresOutput() }); var structures = new StructureCollection <StabilityPointStructure>(); var context = new StabilityPointStructuresContext(structures, failureMechanism, assessmentSection); string textBoxMessage = null; DialogBoxHandler = (name, wnd) => { var helper = new MessageBoxTester(wnd); textBoxMessage = helper.Text; if (isActionConfirmed) { helper.ClickOk(); } else { helper.ClickCancel(); } }; using (var plugin = new StabilityPointStructuresPlugin()) { plugin.Gui = gui; ImportInfo importInfo = GetImportInfo(plugin); // Call bool updatesVerified = importInfo.VerifyUpdates(context); // Assert string expectedInquiryMessage = "Als u kunstwerken 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 IsEnabled_SourcePathNull_ReturnFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); var structures = new StructureCollection <StabilityPointStructure>(); var context = new StabilityPointStructuresContext(structures, failureMechanism, assessmentSection); // Call bool isEnabled = updateInfo.IsEnabled(context); // Assert Assert.IsFalse(isEnabled); mocks.VerifyAll(); }
public void ParameteredConstructor_ExpectedValues() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); // Call var context = new StabilityPointStructuresContext(failureMechanism.StabilityPointStructures, failureMechanism, assessmentSection); // Assert Assert.IsInstanceOf <ObservableWrappedObjectContextBase <StructureCollection <StabilityPointStructure> > >(context); Assert.AreSame(failureMechanism, failureMechanism); Assert.AreSame(failureMechanism.StabilityPointStructures, context.WrappedData); Assert.AreSame(assessmentSection, context.AssessmentSection); mocks.VerifyAll(); }
public void CreateInstance_WithContext_NewPropertiesWithContextAsData() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); var collection = new StructureCollection <StabilityPointStructure>(); var context = new StabilityPointStructuresContext(collection, failureMechanism, assessmentSection); // Call IObjectProperties objectProperties = info.CreateInstance(context); // Assert Assert.IsInstanceOf <StructureCollectionProperties <StabilityPointStructure> >(objectProperties); Assert.AreSame(collection, objectProperties.Data); mocks.VerifyAll(); }
public void CreateFileImporter_ValidInput_ReturnFileImporter() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); var structures = new StructureCollection <StabilityPointStructure>(); var importTarget = new StabilityPointStructuresContext(structures, failureMechanism, assessmentSection); // Call IFileImporter importer = updateInfo.CreateFileImporter(importTarget, "This is valid"); // Assert Assert.IsInstanceOf <StabilityPointStructuresImporter>(importer); 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 <StabilityPointStructure>(); structures.AddRange(Enumerable.Empty <StabilityPointStructure>(), expectedFilePath); var failureMechanism = new StabilityPointStructuresFailureMechanism(); var context = new StabilityPointStructuresContext(structures, failureMechanism, assessmentSection); // Call string currentPath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(expectedFilePath, currentPath); mocks.VerifyAll(); }
public void IsEnabled_SourcePathSet_ReturnTrue() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); failureMechanism.StabilityPointStructures.AddRange(Enumerable.Empty <StabilityPointStructure>(), "some path"); var context = new StabilityPointStructuresContext(failureMechanism.StabilityPointStructures, failureMechanism, assessmentSection); // Call bool isEnabled = updateInfo.IsEnabled(context); // Assert Assert.IsTrue(isEnabled); mocks.VerifyAll(); }
public void ChildNodeObjects_Always_ReturnStabilityPointStructures() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); StabilityPointStructure structure1 = new TestStabilityPointStructure("id structure1"); StabilityPointStructure structure2 = new TestStabilityPointStructure("id structure2"); var failureMechanism = new StabilityPointStructuresFailureMechanism(); failureMechanism.StabilityPointStructures.AddRange(new[] { structure1, structure2 }, "path"); var context = new StabilityPointStructuresContext(failureMechanism.StabilityPointStructures, failureMechanism, assessmentSection); using (var plugin = new StabilityPointStructuresPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call object[] children = info.ChildNodeObjects(context); // Assert Assert.AreEqual(2, children.Length); Assert.AreSame(structure1, children.ElementAt(0)); Assert.AreSame(structure2, children.ElementAt(1)); } mocks.VerifyAll(); }