public void EditValue_WithCurrentItemNotInAvailableItems_ReturnsOriginalValue()
        {
            // Setup
            var selectableTargetProbability = new SelectableTargetProbability(
                new AssessmentSectionStub(), Enumerable.Empty <HydraulicBoundaryLocationCalculation>(),
                WaveConditionsInputWaterLevelType.None, 0.1);

            var properties = new ObjectPropertiesWithSelectableTargetProbability(
                selectableTargetProbability, Enumerable.Empty <SelectableTargetProbability>());

            var propertyBag = new DynamicPropertyBag(properties);
            var editor      = new WaveConditionsInputContextTargetProbabilitySelectionEditor();
            var someValue   = new object();

            var mocks             = new MockRepository();
            var serviceProvider   = mocks.Stub <IServiceProvider>();
            var service           = mocks.Stub <IWindowsFormsEditorService>();
            var descriptorContext = mocks.Stub <ITypeDescriptorContext>();

            serviceProvider.Stub(p => p.GetService(null)).IgnoreArguments().Return(service);
            descriptorContext.Stub(c => c.Instance).Return(propertyBag);
            mocks.ReplayAll();

            // Call
            object result = editor.EditValue(descriptorContext, serviceProvider, someValue);

            // Assert
            Assert.AreSame(someValue, result);
            mocks.VerifyAll();
        }
        public void EditValue_WithCurrentItemInAvailableItems_ReturnsCurrentItem()
        {
            // Setup
            IAssessmentSection assessmentSection = new AssessmentSectionStub();

            const WaveConditionsInputWaterLevelType waterLevelType = WaveConditionsInputWaterLevelType.MaximumAllowableFloodingProbability;
            const double targetProbability = 0.1;

            var selectableTargetProbability = new SelectableTargetProbability(assessmentSection, assessmentSection.WaterLevelCalculationsForMaximumAllowableFloodingProbability, waterLevelType, targetProbability);
            var properties = new ObjectPropertiesWithSelectableTargetProbability(
                selectableTargetProbability,
                new[]
            {
                new SelectableTargetProbability(assessmentSection, assessmentSection.WaterLevelCalculationsForMaximumAllowableFloodingProbability, waterLevelType, targetProbability)
            });

            var propertyBag = new DynamicPropertyBag(properties);
            var editor      = new WaveConditionsInputContextTargetProbabilitySelectionEditor();
            var someValue   = new object();

            var mocks             = new MockRepository();
            var serviceProvider   = mocks.Stub <IServiceProvider>();
            var service           = mocks.Stub <IWindowsFormsEditorService>();
            var descriptorContext = mocks.Stub <ITypeDescriptorContext>();

            serviceProvider.Stub(p => p.GetService(null)).IgnoreArguments().Return(service);
            descriptorContext.Stub(c => c.Instance).Return(propertyBag);
            mocks.ReplayAll();

            // Call
            object result = editor.EditValue(descriptorContext, serviceProvider, someValue);

            // Assert
            Assert.AreEqual(selectableTargetProbability, result);
            mocks.VerifyAll();
        }