Beispiel #1
0
        public void CreateInstance_WithContext_NewPropertiesWithInputContextAsData()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var calculation      = new GrassCoverErosionInwardsCalculation();
            var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
            var context          = new GrassCoverErosionInwardsInputContext(
                calculation.InputParameters,
                calculation,
                failureMechanism,
                assessmentSection);

            // Call
            IObjectProperties objectProperties = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <GrassCoverErosionInwardsInputContextProperties>(objectProperties);
            Assert.AreSame(context, objectProperties.Data);

            mocks.VerifyAll();
        }
        public void EditValue_WithCurrentItemInAvailableItems_ReturnsCurrentItem()
        {
            // Setup
            DikeProfile dikeProfile      = DikeProfileTestFactory.CreateDikeProfile();
            var         failureMechanism = new GrassCoverErosionInwardsFailureMechanism();

            failureMechanism.DikeProfiles.AddRange(new[]
            {
                dikeProfile
            }, "path");

            var grassCoverErosionInwardsInput = new GrassCoverErosionInwardsInput
            {
                DikeProfile = dikeProfile
            };
            var grassCoverErosionInwardsCalculation = new GrassCoverErosionInwardsCalculation();

            var assessmentSection = mockRepository.Stub <IAssessmentSection>();
            var inputContext      = new GrassCoverErosionInwardsInputContext(grassCoverErosionInwardsInput,
                                                                             grassCoverErosionInwardsCalculation,
                                                                             failureMechanism,
                                                                             assessmentSection);

            var handler    = mockRepository.Stub <IObservablePropertyChangeHandler>();
            var properties = new GrassCoverErosionInwardsInputContextProperties(inputContext, handler);

            var editor      = new GrassCoverErosionInwardsInputContextDikeProfileEditor();
            var propertyBag = new DynamicPropertyBag(properties);

            var serviceProvider   = mockRepository.StrictMock <IServiceProvider>();
            var service           = mockRepository.StrictMock <IWindowsFormsEditorService>();
            var descriptorContext = mockRepository.StrictMock <ITypeDescriptorContext>();

            serviceProvider.Expect(p => p.GetService(null)).IgnoreArguments().Return(service);
            service.Expect(s => s.DropDownControl(null)).IgnoreArguments();
            service.Expect(s => s.CloseDropDown()).IgnoreArguments();
            descriptorContext.Expect(c => c.Instance).Return(propertyBag).Repeat.Twice();
            mockRepository.ReplayAll();

            var someValue = new object();

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

            // Assert
            Assert.AreSame(dikeProfile, result);

            mockRepository.VerifyAll();
        }
        public void Text_Always_ReturnsTextFromResource()
        {
            // Setup
            var grassCoverErosionInwardsInputContext = new GrassCoverErosionInwardsInputContext(
                new GrassCoverErosionInwardsInput(),
                new GrassCoverErosionInwardsCalculation(),
                new GrassCoverErosionInwardsFailureMechanism(),
                mocksRepository.Stub <IAssessmentSection>());

            mocksRepository.ReplayAll();

            // Call
            string text = info.Text(grassCoverErosionInwardsInputContext);

            // Assert
            Assert.AreEqual("Invoer", text);
        }
        public void Image_Always_ReturnsSetImage()
        {
            // Setup
            var grassCoverErosionInwardsInputContext = new GrassCoverErosionInwardsInputContext(
                new GrassCoverErosionInwardsInput(),
                new GrassCoverErosionInwardsCalculation(),
                new GrassCoverErosionInwardsFailureMechanism(),
                mocksRepository.Stub <IAssessmentSection>());

            mocksRepository.ReplayAll();

            // Call
            Image image = info.Image(grassCoverErosionInwardsInputContext);

            // Assert
            TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GenericInputOutputIcon, image);
        }
Beispiel #5
0
        public void GetViewData_Always_ReturnsWrappedCalculation()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var input       = new GrassCoverErosionInwardsInput();
            var calculation = new GrassCoverErosionInwardsCalculation();
            var context     = new GrassCoverErosionInwardsInputContext(input,
                                                                       calculation,
                                                                       new GrassCoverErosionInwardsFailureMechanism(),
                                                                       assessmentSection);
            // Call
            object viewData = info.GetViewData(context);

            // Assert
            Assert.AreSame(calculation, viewData);
            mocks.VerifyAll();
        }
Beispiel #6
0
        public void ConstructorWithData_Always_ExpectedPropertiesSet()
        {
            // Setup
            var assessmentSection = mocksRepository.Stub <IAssessmentSection>();

            mocksRepository.ReplayAll();

            var input            = new GrassCoverErosionInwardsInput();
            var calculation      = new GrassCoverErosionInwardsCalculation();
            var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();

            // Call
            var context = new GrassCoverErosionInwardsInputContext(input, calculation, failureMechanism, assessmentSection);

            // Assert
            Assert.IsInstanceOf <GrassCoverErosionInwardsContext <GrassCoverErosionInwardsInput> >(context);
            Assert.AreSame(input, context.WrappedData);
            Assert.AreSame(calculation, context.Calculation);
            Assert.AreSame(failureMechanism, context.FailureMechanism);
            Assert.AreSame(assessmentSection, context.AssessmentSection);
            mocksRepository.VerifyAll();
        }