public void Read_EntityWithStochasticSoilModel_ReturnCalculationScenarioWithInputObjectWithStochasticSoilModelPropertiesSet()
        {
            // Setup
            var random = new Random(21);
            MacroStabilityInwardsStochasticSoilModel stochasticSoilModel =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel();
            var stochasticSoilModelEntity = new StochasticSoilModelEntity();

            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(random.NextDouble(),
                                                                                       MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D());
            var stochasticSoilProfileEntity = new MacroStabilityInwardsStochasticSoilProfileEntity
            {
                StochasticSoilModelEntity = stochasticSoilModelEntity
            };

            var collector = new ReadConversionCollector();

            collector.Read(stochasticSoilModelEntity, stochasticSoilModel);
            collector.Read(stochasticSoilProfileEntity, stochasticSoilProfile);

            MacroStabilityInwardsCalculationEntity entity = CreateValidCalculationEntity();

            entity.MacroStabilityInwardsStochasticSoilProfileEntity = stochasticSoilProfileEntity;

            // Call
            MacroStabilityInwardsCalculationScenario calculation = entity.Read(collector);

            // Assert
            MacroStabilityInwardsInput inputParameters = calculation.InputParameters;

            Assert.AreSame(stochasticSoilModel, inputParameters.StochasticSoilModel);
            Assert.AreSame(stochasticSoilProfile, inputParameters.StochasticSoilProfile);
        }
        public void Create_CalculationWithAlreadyRegisteredStochasticSoilProfile_ReturnsEntityWithStochasticSoilModelEntity()
        {
            // Setup
            var random = new Random(21);
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(random.NextDouble(),
                                                                                       MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D());
            var scenario = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    StochasticSoilProfile = stochasticSoilProfile
                }
            };

            var registry = new PersistenceRegistry();
            var stochasticSoilProfileEntity = new MacroStabilityInwardsStochasticSoilProfileEntity();

            registry.Register(stochasticSoilProfileEntity, stochasticSoilProfile);

            // Call
            MacroStabilityInwardsCalculationEntity entity = scenario.Create(registry, 0);

            // Assert
            Assert.IsNotNull(entity);
            MacroStabilityInwardsStochasticSoilProfileEntity expectedStochasticSoilProfileEntity = registry.Get(stochasticSoilProfile);

            Assert.AreSame(expectedStochasticSoilProfileEntity, entity.MacroStabilityInwardsStochasticSoilProfileEntity);
        }
        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 MacroStabilityInwardsInputContextStochasticSoilProfileSelectionEditor();
            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(stochasticSoilProfile, result);

            mockRepository.VerifyAll();
        }
Esempio n. 4
0
        private static IEnumerable <IMacroStabilityInwardsSoilProfile <IMacroStabilityInwardsSoilLayer> > GetMacroStabilityInwardsSoilProfiles()
        {
            yield return(MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D());

            yield return(MacroStabilityInwardsSoilProfile2DTestFactory.CreateMacroStabilityInwardsSoilProfile2D());
        }