public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase()); var assessmentSectionToRemove = mocks.Stub <IAssessmentSection>(); assessmentSectionToRemove.Stub(asm => asm.GetFailureMechanisms()).Return(new[] { new MacroStabilityInwardsFailureMechanism() }); mocks.ReplayAll(); using (var view = new MacroStabilityInwardsCalculationsView(new CalculationGroup(), new MacroStabilityInwardsFailureMechanism(), assessmentSection)) { // Call bool closeForData = info.CloseForData(view, assessmentSectionToRemove); // Assert Assert.IsFalse(closeForData); } mocks.VerifyAll(); }
public void CloseForData_AssessmentSectionRemovedWithoutFailureMechanism_ReturnsFalse() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(Array.Empty <IFailureMechanism>()); assessmentSection.Stub(asm => asm.SpecificFailureMechanisms).Return(new ObservableList <SpecificFailureMechanism>()); mocks.ReplayAll(); var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism(); using (var view = new NonAdoptableWithProfileProbabilityFailureMechanismResultView <GrassCoverSlipOffOutwardsFailureMechanism>( failureMechanism.SectionResults, failureMechanism, assessmentSection, (fm, ass) => new FailureMechanismAssemblyResultWrapper(double.NaN, AssemblyMethod.Manual), fm => fm.GeneralInput.ApplyLengthEffectInSection, sr => FailureMechanismSectionAssemblyResultWrapperTestFactory.Create())) { // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsFalse(closeForData); } mocks.VerifyAll(); }
public void CloseForData_AssessmentSectionRemovedWithoutFailureMechanism_ReturnsFalse() { // Setup var assessmentSection = new AssessmentSectionStub(); using (var calculationsView = new GrassCoverErosionInwardsCalculationsView(new CalculationGroup(), new GrassCoverErosionInwardsFailureMechanism(), assessmentSection)) { bool closeForData = info.CloseForData(calculationsView, assessmentSection); // Assert Assert.IsFalse(closeForData); } }
public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() { // Setup var assessmentSection = new AssessmentSectionStub(); using (var view = new HeightStructuresCalculationsView(new CalculationGroup(), new HeightStructuresFailureMechanism(), assessmentSection)) { bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsFalse(closeForData); } }
public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() { // Setup var random = new Random(21); var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>()); var view = new AssessmentSectionExtendedView(assessmentSection); // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsTrue(closeForData); }
public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() { // Setup AssessmentSection assessmentSection = CreateAssessmentSection(); using (var view = new AssemblyResultPerSectionMapView(assessmentSection)) { // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsTrue(closeForData); } }
public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() { // Setup var random = new Random(21); var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>()); using (var view = new FailureMechanismSectionAssemblyGroupsView(assessmentSection)) { // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsTrue(closeForData); } }
public void CloseViewForData_ViewDataNull_ReturnsFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); using (var plugin = new DuneErosionPlugin()) using (var view = new DuneLocationCalculationsView(new ObservableList <DuneLocationCalculation>(), new DuneErosionFailureMechanism(), assessmentSection, () => 0.01, () => "1/100")) { ViewInfo info = GetInfo(plugin); // Call bool closeForData = info.CloseForData(view, null); // Assert Assert.IsFalse(closeForData); } mocks.VerifyAll(); }
public void CloseViewForData_ForOtherObjectType_ReturnsFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.GetFailureMechanisms()).Return(new[] { new DuneErosionFailureMechanism() }); assessmentSection.Stub(a => a.Attach(null)).IgnoreArguments(); assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); mocks.ReplayAll(); using (var plugin = new DuneErosionPlugin()) using (var view = new DuneLocationCalculationsView(new ObservableList <DuneLocationCalculation>(), new DuneErosionFailureMechanism(), assessmentSection, () => 0.01, () => "1/100")) { ViewInfo info = GetInfo(plugin); // Call bool closeForData = info.CloseForData(view, new object()); // Assert Assert.IsFalse(closeForData); } mocks.VerifyAll(); }
public void CloseViewForData_ForMatchingContext_ReturnsTrue() { // Setup const double targetProbability = 0.01; var context = new WaveHeightCalculationsForUserDefinedTargetProbabilityContext( new HydraulicBoundaryLocationCalculationsForTargetProbability(targetProbability), new AssessmentSectionStub()); using (var view = new WaveHeightCalculationsView(context.WrappedData.HydraulicBoundaryLocationCalculations, new AssessmentSectionStub(), () => targetProbability, () => "1/100")) using (var plugin = new RiskeerPlugin()) { view.Data = context.WrappedData.HydraulicBoundaryLocationCalculations; ViewInfo info = GetViewInfo(plugin); // Call bool closeForData = info.CloseForData(view, context); // Assert Assert.IsTrue(closeForData); } }
public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() { // Setup var assessmentSection = new AssessmentSectionStub(); var otherAssessmentSection = new AssessmentSectionStub(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism, assessmentSection); // Call bool closeForData = info.CloseForData(view, otherAssessmentSection); // Assert Assert.IsFalse(closeForData); }
public void CloseViewForData_ForNonMatchingContext_ReturnsFalse() { // Setup const double targetProbability = 0.01; var context = new WaterLevelCalculationsForUserDefinedTargetProbabilityContext( new HydraulicBoundaryLocationCalculationsForTargetProbability(targetProbability), new AssessmentSectionStub()); var otherCalculations = new ObservableList <HydraulicBoundaryLocationCalculation>(); using (var view = new DesignWaterLevelCalculationsView(otherCalculations, new AssessmentSectionStub(), () => targetProbability, () => "1/100")) using (var plugin = new RiskeerPlugin()) { view.Data = otherCalculations; ViewInfo info = GetViewInfo(plugin); // Call bool closeForData = info.CloseForData(view, context); // Assert Assert.IsFalse(closeForData); } }
public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnFalse() { // Setup var unrelatedFailureMechanism = new HeightStructuresFailureMechanism(); var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(new[] { unrelatedFailureMechanism }); mocks.ReplayAll(); using (var view = new HeightStructuresScenariosView(new CalculationGroup(), new HeightStructuresFailureMechanism())) { // Precondition Assert.AreNotSame(view.Data, unrelatedFailureMechanism.CalculationsGroup); // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsFalse(closeForData); } mocks.VerifyAll(); }
public void CloseForData_AssessmentSectionRemovedWithoutFailureMechanism_ReturnsFalse() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(Array.Empty <IFailureMechanism>()); mocks.ReplayAll(); var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); using (var view = new NonAdoptableWithProfileProbabilityFailureMechanismResultView <WaveImpactAsphaltCoverFailureMechanism>( failureMechanism.SectionResults, failureMechanism, assessmentSection, (fm, ass) => new FailureMechanismAssemblyResultWrapper(double.NaN, AssemblyMethod.Manual), fm => true, sr => FailureMechanismSectionAssemblyResultWrapperTestFactory.Create())) { // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsFalse(closeForData); } mocks.VerifyAll(); }
public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() { // Setup var assessmentSection = new AssessmentSectionStub(); var otherAssessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new DuneErosionFailureMechanism(); var view = new DuneErosionFailureMechanismView(failureMechanism, assessmentSection); // Call bool closeForData = info.CloseForData(view, otherAssessmentSection); // Assert Assert.IsFalse(closeForData); mocks.VerifyAll(); }
public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() { // Setup var mocks = new MockRepository(); IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocks); mocks.ReplayAll(); using (new AssemblyToolCalculatorFactoryConfig()) using (var view = new AssessmentSectionAssemblyGroupsView(assessmentSection.FailureMechanismContribution)) { // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsTrue(closeForData); } mocks.VerifyAll(); }
public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() { // Setup var assessmentSection = new AssessmentSectionStub(); var otherAssessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism(); using (StandAloneFailureMechanismView <GrassCoverSlipOffInwardsFailureMechanism, NonAdoptableWithProfileProbabilityFailureMechanismSectionResult> view = CreateView(failureMechanism, assessmentSection)) { // Call bool closeForData = info.CloseForData(view, otherAssessmentSection); // Assert Assert.IsFalse(closeForData); } mocks.VerifyAll(); }
public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnFalse() { using (var view = new ClosingStructuresScenariosView(new CalculationGroup(), new ClosingStructuresFailureMechanism())) { // Call bool closeForData = info.CloseForData(view, new ClosingStructuresFailureMechanism()); // Assert Assert.IsFalse(closeForData); } }
private bool ShouldRemoveViewForData(IView view, object data) { ViewInfo viewInfo = openedViewLookup.Single(openedView => ReferenceEquals(view, openedView.Value.Item1)).Value.Item2; if (viewInfo == null) { return(false); } bool isViewData = data.GetType().Implements(viewInfo.DataType) && Equals(viewInfo.GetViewData(data), view.Data); return(isViewData || viewInfo.CloseForData(view, data)); }
public void CloseForData_AssessmentSectionRemovedWithoutFailureMechanism_ReturnsFalse() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(Array.Empty <IFailureMechanism>()); assessmentSection.Stub(asm => asm.SpecificFailureMechanisms).Return(new ObservableList <SpecificFailureMechanism>()); mocks.ReplayAll(); var failureMechanism = new PipingStructureFailureMechanism(); using (var view = new NonAdoptableFailureMechanismResultView <PipingStructureFailureMechanism>( failureMechanism.SectionResults, failureMechanism, assessmentSection, (fm, ass) => new FailureMechanismAssemblyResultWrapper(double.NaN, AssemblyMethod.Manual))) { // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsFalse(closeForData); } mocks.VerifyAll(); }
public void CloseViewForData_ForNonMatchingFailureMechanism_ReturnsFalse() { // Setup using (var plugin = new DuneErosionPlugin()) using (var view = new DuneLocationCalculationsView(new ObservableList <DuneLocationCalculation>(), new DuneErosionFailureMechanism(), new AssessmentSectionStub(), () => 0.01, () => "1/100")) { ViewInfo info = GetInfo(plugin); // Call bool closeForData = info.CloseForData(view, new DuneErosionFailureMechanism()); // Assert Assert.IsFalse(closeForData); } }
public void CloseViewForData_ForOtherObjectType_ReturnsFalse() { // Setup var assessmentSectionA = new AssessmentSectionStub(); using (var view = new DesignWaterLevelCalculationsView(new ObservableList <HydraulicBoundaryLocationCalculation>(), assessmentSectionA, () => 0.01, () => "1/100")) using (var plugin = new RiskeerPlugin()) { ViewInfo info = GetViewInfo(plugin); // Call bool closeForData = info.CloseForData(view, new object()); // Assert Assert.IsFalse(closeForData); } }
public void CloseViewForData_ForMatchingAssessmentSection_ReturnsTrue() { // Setup var assessmentSection = new AssessmentSectionStub(); using (var view = new WaveHeightCalculationsView(new ObservableList <HydraulicBoundaryLocationCalculation>(), assessmentSection, () => 0.01, () => "1/100")) using (var plugin = new RiskeerPlugin()) { ViewInfo info = GetViewInfo(plugin); // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsTrue(closeForData); } }
public void CloseForData_AssessmentSectionRemovedWithoutFailureMechanism_ReturnsFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[0]); mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var view = new GrassCoverErosionInwardsFailureMechanismResultView(failureMechanism.SectionResults, failureMechanism, assessmentSection); // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsFalse(closeForData); mocks.VerifyAll(); }
public void CloseForData_AssessmentSectionRemovedWithoutPipingFailureMechanism_ReturnsFalse() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[0]); mocks.ReplayAll(); using (var view = new PipingScenariosView(new CalculationGroup(), new PipingFailureMechanism(), assessmentSection)) { // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsFalse(closeForData); } mocks.VerifyAll(); }
public void CloseForData_AssessmentSectionRemovedWithoutFailureMechanism_ReturnsFalse() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(Array.Empty <IFailureMechanism>()); mocks.ReplayAll(); var failureMechanism = new PipingFailureMechanism(); using (var view = new PipingFailureMechanismResultView(failureMechanism.SectionResults, failureMechanism, assessmentSection)) { // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsFalse(closeForData); } mocks.VerifyAll(); }
public void CloseForData_AssessmentSectionRemovedWithoutFailureMechanism_ReturnsFalse() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(Array.Empty <IFailureMechanism>()); mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); var view = new StructuresFailureMechanismResultView <HeightStructuresFailureMechanism, HeightStructuresInput>( failureMechanism.SectionResults, failureMechanism, assessmentSection, (fm, ass) => new FailureMechanismAssemblyResultWrapper(double.NaN, AssemblyMethod.Manual)); // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsFalse(closeForData); mocks.VerifyAll(); }
public void CloseForData_AssessmentSectionRemovedWithoutFailureMechanism_ReturnsFalse() { // Setup var calculationsGroup = new CalculationGroup(); var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[0]); mocks.ReplayAll(); using (var view = new MacroStabilityInwardsScenariosView(calculationsGroup, new MacroStabilityInwardsFailureMechanism())) { // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsFalse(closeForData); } mocks.VerifyAll(); }
public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() { // Setup var otherAssessmentSection = mocks.Stub <IAssessmentSection>(); otherAssessmentSection.Stub(ass => ass.SpecificFailureMechanisms).Return(new ObservableList <SpecificFailureMechanism>()); otherAssessmentSection.Stub(ass => ass.GetFailureMechanisms()).Return(Enumerable.Empty <IFailureMechanism>()); mocks.ReplayAll(); var failureMechanism = new SpecificFailureMechanism(); var assessmentSection = new AssessmentSectionStub(); var view = new SpecificFailureMechanismView(failureMechanism, assessmentSection); // Call bool closeForData = info.CloseForData(view, otherAssessmentSection); // Assert Assert.IsFalse(closeForData); mocks.VerifyAll(); }
protected override bool ShouldCloseMethod(IView view, object o) { return(info.CloseForData(view, o)); }