public void ParameteredConstructor_ExpectedValues() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var calculation = new MacroStabilityInwardsCalculationScenario(); var surfaceLines = new[] { new MacroStabilityInwardsSurfaceLine(string.Empty) }; MacroStabilityInwardsStochasticSoilModel[] stochasticSoilModels = { MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel() }; var failureMechanism = new MacroStabilityInwardsFailureMechanism(); // Call var context = new MacroStabilityInwardsInputContext(calculation.InputParameters, calculation, surfaceLines, stochasticSoilModels, failureMechanism, assessmentSection); // Assert Assert.IsInstanceOf <MacroStabilityInwardsContext <MacroStabilityInwardsInput> >(context); Assert.AreSame(calculation.InputParameters, context.WrappedData); Assert.AreSame(calculation, context.MacroStabilityInwardsCalculation); Assert.AreSame(failureMechanism, context.FailureMechanism); Assert.AreSame(assessmentSection, context.AssessmentSection); CollectionAssert.AreEqual(surfaceLines, context.AvailableMacroStabilityInwardsSurfaceLines); CollectionAssert.AreEqual(stochasticSoilModels, context.AvailableStochasticSoilModels); mocks.VerifyAll(); }
public void EditValue_WithCurrentItemInAvailableItems_ReturnsCurrentItem() { // Setup var mockRepository = new MockRepository(); var provider = mockRepository.DynamicMock <IServiceProvider>(); var service = mockRepository.DynamicMock <IWindowsFormsEditorService>(); var context = mockRepository.DynamicMock <ITypeDescriptorContext>(); var assessmentSection = mockRepository.Stub <IAssessmentSection>(); var handler = mockRepository.Stub <IObservablePropertyChangeHandler>(); var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); surfaceLine.SetGeometry(new[] { new Point3D(0.0, 0.0, 0.0), new Point3D(1.0, 0.0, 1.0) }); var calculation = new MacroStabilityInwardsCalculationScenario(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { SurfaceLine = surfaceLine }; var inputParametersContext = new MacroStabilityInwardsInputContext(input, calculation, new[] { surfaceLine }, Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(), failureMechanism, assessmentSection); var properties = new MacroStabilityInwardsInputContextProperties(inputParametersContext, AssessmentSectionTestHelper.GetTestAssessmentLevel, handler); var editor = new MacroStabilityInwardsInputContextSurfaceLineSelectionEditor(); var someValue = new object(); var propertyBag = new DynamicPropertyBag(properties); provider.Expect(p => p.GetService(null)).IgnoreArguments().Return(service); service.Expect(s => s.DropDownControl(null)).IgnoreArguments(); context.Expect(c => c.Instance).Return(propertyBag); mockRepository.ReplayAll(); // Call object result = editor.EditValue(context, provider, someValue); // Assert Assert.AreSame(surfaceLine, result); mockRepository.VerifyAll(); }
public void CreateInstance_WithContextAndNormativeProbabilityTypeSignalFloodingProbability_ExpectedProperties() { // Setup var assessmentSection = new AssessmentSectionStub { FailureMechanismContribution = { NormativeProbabilityType = NormativeProbabilityType.SignalFloodingProbability } }; var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); var scenario = new MacroStabilityInwardsCalculationScenario { InputParameters = { HydraulicBoundaryLocation = hydraulicBoundaryLocation } }; var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var context = new MacroStabilityInwardsInputContext( scenario.InputParameters, scenario, Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(), Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(), failureMechanism, assessmentSection); assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] { hydraulicBoundaryLocation }, true); // Call IObjectProperties objectProperties = info.CreateInstance(context); // Assert Assert.IsInstanceOf <MacroStabilityInwardsInputContextProperties>(objectProperties); Assert.AreSame(context, objectProperties.Data); double expectedAssessmentLevel = assessmentSection.WaterLevelCalculationsForSignalFloodingProbability.ElementAt(0).Output.Result; Assert.AreEqual(expectedAssessmentLevel, ((MacroStabilityInwardsInputContextProperties)objectProperties).AssessmentLevel); }
public void CreateInstance_WithContext_SetsDataCorrectly() { // Setup var assessmentSection = new AssessmentSectionStub(); var calculation = new MacroStabilityInwardsCalculationScenario(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()); var calculationInputContext = new MacroStabilityInwardsInputContext(input, calculation, Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(), Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(), new MacroStabilityInwardsFailureMechanism(), assessmentSection); // Call IView view = info.CreateInstance(calculationInputContext); // Assert Assert.AreSame(calculation, view.Data); mocks.VerifyAll(); }
public void GetViewData_Always_ReturnsWrappedCalculation() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var calculation = new MacroStabilityInwardsCalculationScenario(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()); var calculationInputContext = new MacroStabilityInwardsInputContext(input, calculation, Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(), Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(), new MacroStabilityInwardsFailureMechanism(), assessmentSection); // Call object viewData = info.GetViewData(calculationInputContext); // Assert Assert.AreSame(calculation, viewData); mocks.VerifyAll(); }