public void AssembleFailureMechanism_WithInput_SetsInputOnCalculator() { // Setup var failureMechanism = new HeightStructuresFailureMechanism { 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 HeightStructuresFailureMechanismAssemblyFactory.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_CalculatorThrowsException_ThrowsAssemblyException() { // Setup var failureMechanism = new HeightStructuresFailureMechanism { 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() => HeightStructuresFailureMechanismAssemblyFactory.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_CalculatorRan_ReturnsExpectedOutput() { // Setup var failureMechanism = new HeightStructuresFailureMechanism { AssemblyResult = { ProbabilityResultType = FailureMechanismAssemblyProbabilityResultType.Automatic } }; var assessmentSection = new AssessmentSectionStub(); using (new AssemblyToolCalculatorFactoryConfig()) { var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance; FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; // Call FailureMechanismAssemblyResultWrapper result = HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(failureMechanism, assessmentSection); // Assert Assert.AreSame(calculator.AssemblyResultOutput, result); } }
private FailureMechanismAssemblyResultRow CreateHeightStructuresFailureMechanismAssemblyResultRow() { HeightStructuresFailureMechanism heightStructures = AssessmentSection.HeightStructures; return(FailureMechanismAssemblyResultRowFactory.CreateRow( heightStructures, () => HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(heightStructures, AssessmentSection))); }
public void AssembleFailureMechanism_AssessmentSectionNull_ThrowsArgumentNullException() { // Setup var failureMechanism = new HeightStructuresFailureMechanism(); // Call void Call() => HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(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() => HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(null, assessmentSection); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("failureMechanism", exception.ParamName); mocks.VerifyAll(); }