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