private FailureMechanismAssemblyResultRow CreateStabilityStoneCoverFailureMechanismAssemblyResultRow() { StabilityStoneCoverFailureMechanism stabilityStoneCover = AssessmentSection.StabilityStoneCover; return(FailureMechanismAssemblyResultRowFactory.CreateRow( stabilityStoneCover, () => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(stabilityStoneCover, AssessmentSection))); }
public void AssembleFailureMechanism_CalculatorThrowsException_ThrowsAssemblyException() { // Setup var failureMechanism = new StabilityStoneCoverFailureMechanism { AssemblyResult = { ProbabilityResultType = FailureMechanismAssemblyProbabilityResultType.Automatic } }; var assessmentSection = new AssessmentSectionStub(); using (new AssemblyToolCalculatorFactoryConfig()) { var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance; FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; calculator.ThrowExceptionOnCalculate = true; // Call void Call() => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(failureMechanism, assessmentSection); // Assert var exception = Assert.Throws <AssemblyException>(Call); Exception innerException = exception.InnerException; Assert.IsInstanceOf <FailureMechanismAssemblyCalculatorException>(innerException); Assert.AreEqual(innerException.Message, exception.Message); } }
public void AssembleFailureMechanism_WithInput_SetsInputOnCalculator() { // Setup var failureMechanism = new StabilityStoneCoverFailureMechanism { AssemblyResult = { ProbabilityResultType = FailureMechanismAssemblyProbabilityResultType.Automatic } }; failureMechanism.SetSections(new[] { FailureMechanismSectionTestFactory.CreateFailureMechanismSection() }, "APath"); var assessmentSection = new AssessmentSectionStub(); using (new AssemblyToolCalculatorFactoryConfig()) { var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; FailureMechanismAssemblyCalculatorStub failureMechanismAssemblyCalculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; // Call StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(failureMechanism, assessmentSection); // Assert Assert.AreEqual(failureMechanism.GeneralInput.N, failureMechanismAssemblyCalculator.FailureMechanismN); Assert.AreSame(calculator.FailureMechanismSectionAssemblyResultOutput.AssemblyResult, failureMechanismAssemblyCalculator.SectionAssemblyResultsInput.Single()); Assert.AreEqual(failureMechanism.GeneralInput.ApplyLengthEffectInSection, failureMechanismAssemblyCalculator.ApplyLengthEffect); } }
public void AssembleFailureMechanism_CalculatorRan_ReturnsExpectedOutput() { // Setup var failureMechanism = new StabilityStoneCoverFailureMechanism { AssemblyResult = { ProbabilityResultType = FailureMechanismAssemblyProbabilityResultType.Automatic } }; var assessmentSection = new AssessmentSectionStub(); using (new AssemblyToolCalculatorFactoryConfig()) { var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance; FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; // Call FailureMechanismAssemblyResultWrapper result = StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(failureMechanism, assessmentSection); // Assert Assert.AreEqual(calculator.AssemblyResultOutput, result); } }
public void AssembleSection_CalculatorThrowsException_ThrowsAssemblyException() { // Setup FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var sectionResult = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResult(section); var failureMechanism = new StabilityStoneCoverFailureMechanism(); var assessmentSection = new AssessmentSectionStub(); using (new AssemblyToolCalculatorFactoryConfig()) { var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; calculator.ThrowExceptionOnCalculate = true; // Call void Call() => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSection( sectionResult, failureMechanism, assessmentSection); // Assert var exception = Assert.Throws <AssemblyException>(Call); Exception innerException = exception.InnerException; Assert.IsInstanceOf <FailureMechanismSectionAssemblyCalculatorException>(innerException); Assert.AreEqual(innerException.Message, exception.Message); } }
public void AssembleFailureMechanism_AssessmentSectionNull_ThrowsArgumentNullException() { // Setup var failureMechanism = new StabilityStoneCoverFailureMechanism(); // Call void Call() => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(failureMechanism, null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("assessmentSection", exception.ParamName); }
public override IEnumerable <ViewInfo> GetViewInfos() { yield return(new RiskeerViewInfo <HydraulicLoadsStateFailureMechanismContext, HydraulicLoadsStateFailureMechanismView>(() => Gui) { GetViewName = (view, context) => context.WrappedData.Name, CreateInstance = context => new HydraulicLoadsStateFailureMechanismView(context.WrappedData, context.Parent) }); yield return(new RiskeerViewInfo <RegistrationStateFailureMechanismContext, RegistrationStateFailureMechanismView>(() => Gui) { GetViewName = (view, context) => context.WrappedData.Name, AdditionalDataCheck = context => context.WrappedData.InAssembly, CreateInstance = context => new RegistrationStateFailureMechanismView(context.WrappedData, context.Parent), CloseForData = CloseFailureMechanismViewForData }); yield return(new RiskeerViewInfo <StabilityStoneCoverFailureMechanismSectionResultContext, IObservableEnumerable <NonAdoptableWithProfileProbabilityFailureMechanismSectionResult>, NonAdoptableWithProfileProbabilityFailureMechanismResultView <StabilityStoneCoverFailureMechanism> >(() => Gui) { GetViewName = (view, context) => RiskeerCommonFormsResources.FailureMechanism_AssessmentResult_DisplayName, CloseForData = CloseFailureMechanismResultViewForData, GetViewData = context => context.WrappedData, CreateInstance = context => { var failureMechanism = (StabilityStoneCoverFailureMechanism)context.FailureMechanism; IAssessmentSection assessmentSection = context.AssessmentSection; return new NonAdoptableWithProfileProbabilityFailureMechanismResultView <StabilityStoneCoverFailureMechanism>( context.WrappedData, failureMechanism, assessmentSection, StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism, fm => fm.GeneralInput.ApplyLengthEffectInSection, sr => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSection(sr, failureMechanism, assessmentSection)); } }); yield return(new RiskeerViewInfo <StabilityStoneCoverWaveConditionsInputContext, StabilityStoneCoverWaveConditionsCalculation, WaveConditionsInputView>(() => Gui) { GetViewName = (view, context) => RiskeerCommonFormsResources.Calculation_Input, CloseForData = RiskeerPluginHelper.ShouldCloseViewWithCalculationData, CreateInstance = context => new WaveConditionsInputView( context.Calculation, () => WaveConditionsInputHelper.GetHydraulicBoundaryLocationCalculation(context.WrappedData, context.AssessmentSection), new StabilityStoneCoverWaveConditionsInputViewStyle()) }); }
public void AssembleSection_AssessmentSectionNull_ThrowsArgumentNullException() { // Setup FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var sectionResult = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResult(section); var failureMechanism = new StabilityStoneCoverFailureMechanism(); // Call void Call() => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSection(sectionResult, failureMechanism, null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("assessmentSection", exception.ParamName); }
public void AssembleFailureMechanism_FailureMechanismNull_ThrowsArgumentNullException() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); // Call void Call() => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(null, assessmentSection); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("failureMechanism", exception.ParamName); mocks.VerifyAll(); }
protected override void CreateMapData() { base.CreateMapData(); MapDataCollection sectionsMapDataCollection = RiskeerMapDataFactory.CreateSectionsMapDataCollection(); sectionsMapData = RiskeerMapDataFactory.CreateFailureMechanismSectionsMapData(); sectionsStartPointMapData = RiskeerMapDataFactory.CreateFailureMechanismSectionsStartPointMapData(); sectionsEndPointMapData = RiskeerMapDataFactory.CreateFailureMechanismSectionsEndPointMapData(); assemblyResultMapLayer = new NonCalculatableFailureMechanismSectionResultsMapLayer <NonAdoptableWithProfileProbabilityFailureMechanismSectionResult>( FailureMechanism, sr => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSection(sr, FailureMechanism, AssessmentSection).AssemblyResult); sectionsMapDataCollection.Add(sectionsMapData); sectionsMapDataCollection.Add(sectionsStartPointMapData); sectionsMapDataCollection.Add(sectionsEndPointMapData); MapDataCollection.Insert(1, sectionsMapDataCollection); MapDataCollection.Insert(2, assemblyResultMapLayer.MapData); }
public void AssembleSection_FailureMechanismNull_ThrowsArgumentNullException() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var sectionResult = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResult(section); // Call void Call() => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSection(sectionResult, null, assessmentSection); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("failureMechanism", exception.ParamName); mocks.VerifyAll(); }
public void AssembleSection_WithInput_SetsInputOnCalculator() { // Setup var random = new Random(21); FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var sectionResult = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResult(section) { IsRelevant = random.NextBoolean(), InitialFailureMechanismResultType = NonAdoptableInitialFailureMechanismResultType.Manual, ManualInitialFailureMechanismResultSectionProbability = random.NextDouble(), FurtherAnalysisType = random.NextEnumValue <FailureMechanismSectionResultFurtherAnalysisType>(), RefinedSectionProbability = random.NextDouble() }; var failureMechanism = new StabilityStoneCoverFailureMechanism(); var assessmentSection = new AssessmentSectionStub(); using (new AssemblyToolCalculatorFactoryConfig()) { var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; // Call StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSection(sectionResult, failureMechanism, assessmentSection); // Assert FailureMechanismSectionAssemblyInput calculatorInput = calculator.FailureMechanismSectionAssemblyInput; FailureMechanismContribution failureMechanismContribution = assessmentSection.FailureMechanismContribution; Assert.AreEqual(failureMechanismContribution.SignalFloodingProbability, calculatorInput.SignalFloodingProbability); Assert.AreEqual(failureMechanismContribution.MaximumAllowableFloodingProbability, calculatorInput.MaximumAllowableFloodingProbability); Assert.AreEqual(sectionResult.IsRelevant, calculatorInput.IsRelevant); Assert.IsTrue(calculatorInput.HasProbabilitySpecified); Assert.AreEqual(sectionResult.ManualInitialFailureMechanismResultSectionProbability, calculatorInput.InitialSectionProbability); Assert.AreEqual(sectionResult.FurtherAnalysisType, calculatorInput.FurtherAnalysisType); Assert.AreEqual(sectionResult.RefinedSectionProbability, calculatorInput.RefinedSectionProbability); } }
public void AssembleSection_CalculatorRan_ReturnsExpectedOutput() { // Setup FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var sectionResult = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResult(section); var failureMechanism = new StabilityStoneCoverFailureMechanism(); var assessmentSection = new AssessmentSectionStub(); using (new AssemblyToolCalculatorFactoryConfig()) { var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; // Call FailureMechanismSectionAssemblyResultWrapper result = StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSection( sectionResult, failureMechanism, assessmentSection); // Assert Assert.AreSame(calculator.FailureMechanismSectionAssemblyResultOutput, result); } }