public void EditValue_WithCurrentItemNotInAvailableItems_ReturnsOriginalValue() { // 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 calculation = new MacroStabilityInwardsCalculationScenario(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { StochasticSoilModel = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel() }; var inputContext = new MacroStabilityInwardsInputContext(input, calculation, Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(), new[] { MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel() }, failureMechanism, assessmentSection); var properties = new MacroStabilityInwardsInputContextProperties(inputContext, AssessmentSectionTestHelper.GetTestAssessmentLevel, handler); var editor = new MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditor(); 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(someValue, result); mockRepository.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>(); MacroStabilityInwardsSoilProfile1D soilProfile = MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D(); var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(1.0, soilProfile); var stochasticSoilModel = new MacroStabilityInwardsStochasticSoilModel("Model", new[] { new Point2D(0, 2), new Point2D(4, 2) }, new[] { stochasticSoilProfile }); var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); surfaceLine.SetGeometry(new[] { new Point3D(2, 1, 0), new Point3D(2, 3, 0) }); var calculation = new MacroStabilityInwardsCalculationScenario(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { SurfaceLine = surfaceLine, StochasticSoilModel = stochasticSoilModel, StochasticSoilProfile = stochasticSoilProfile }; var inputParametersContext = new MacroStabilityInwardsInputContext(input, calculation, Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(), new[] { stochasticSoilModel }, failureMechanism, assessmentSection); var properties = new MacroStabilityInwardsInputContextProperties(inputParametersContext, AssessmentSectionTestHelper.GetTestAssessmentLevel, handler); var editor = new MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditor(); 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(stochasticSoilModel, result); mockRepository.VerifyAll(); }