Exemplo n.º 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 CreateInstance_WithContext_SetsDataCorrectly()
        {
            // Setup
            var mockRepository    = new MockRepository();
            var assessmentSection = mockRepository.Stub <IAssessmentSection>();

            mockRepository.ReplayAll();

            var context = new DuneLocationCalculationsForUserDefinedTargetProbabilityContext(new DuneLocationCalculationsForTargetProbability(0.1),
                                                                                             new DuneErosionFailureMechanism(),
                                                                                             assessmentSection);

            using (var plugin = new DuneErosionPlugin())
            {
                PropertyInfo info = GetInfo(plugin);

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

                // Assert
                Assert.IsInstanceOf <DuneLocationCalculationsForUserDefinedTargetProbabilityProperties>(objectProperties);
                Assert.AreSame(context.WrappedData, objectProperties.Data);
            }

            mockRepository.VerifyAll();
        }
Exemplo n.º 3
0
        public void CreateInstance_WithContext_SetsFailureMechanismContributionAsData()
        {
            // Setup
            var  mocks             = new MockRepository();
            var  assessmentSection = mocks.Stub <IAssessmentSection>();
            var  viewCommands      = mocks.Stub <IViewCommands>();
            IGui gui = StubFactory.CreateGuiStub(mocks);

            gui.Stub(g => g.ViewCommands).Return(viewCommands);
            mocks.ReplayAll();

            using (var plugin = new RiskeerPlugin())
            {
                plugin.Gui = gui;

                FailureMechanismContribution failureMechanismContribution = FailureMechanismContributionTestFactory.CreateFailureMechanismContribution();
                var context = new NormContext(failureMechanismContribution, assessmentSection);

                PropertyInfo info = GetInfo(plugin);

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

                // Assert
                Assert.IsInstanceOf <NormProperties>(objectProperties);
                Assert.AreSame(failureMechanismContribution, objectProperties.Data);
            }

            mocks.VerifyAll();
        }
Exemplo n.º 4
0
        public void CreateInstance_WithContext_SetsDataCorrectly()
        {
            // Setup
            var mockRepository    = new MockRepository();
            var assessmentSection = mockRepository.Stub <IAssessmentSection>();

            mockRepository.ReplayAll();

            var calculationsForTargetProbability = new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1);

            var context = new WaveHeightCalculationsForUserDefinedTargetProbabilityContext(calculationsForTargetProbability,
                                                                                           assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                PropertyInfo info = GetInfo(plugin);

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

                // Assert
                Assert.IsInstanceOf <WaveHeightCalculationsForUserDefinedTargetProbabilityProperties>(objectProperties);
                Assert.AreSame(calculationsForTargetProbability.HydraulicBoundaryLocationCalculations, objectProperties.Data);
            }

            mockRepository.VerifyAll();
        }
        public void CreateInstance_WithContextThatHasInputWithSpecificWaterLevelType_ExpectedProperties(
            IAssessmentSection assessmentSection,
            Action <WaveConditionsInput> configureInputAction,
            RoundedDouble expectedAssessmentLevel)
        {
            // Setup
            var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation();

            configureInputAction(calculation.InputParameters);

            var context = new GrassCoverErosionOutwardsWaveConditionsInputContext(calculation.InputParameters,
                                                                                  calculation,
                                                                                  assessmentSection,
                                                                                  Enumerable.Empty <ForeshoreProfile>());

            using (var plugin = new GrassCoverErosionOutwardsPlugin())
            {
                PropertyInfo info = GetInfo(plugin);

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

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

                Assert.AreEqual(expectedAssessmentLevel, ((GrassCoverErosionOutwardsWaveConditionsInputContextProperties)objectProperties).AssessmentLevel);
            }
        }
        public void CreateInstance_WithContext_SetsData()
        {
            // Setup
            var  mocks             = new MockRepository();
            var  assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
            var  viewCommands      = mocks.Stub <IViewCommands>();
            IGui gui = StubFactory.CreateGuiStub(mocks);

            gui.Stub(g => g.ViewCommands).Return(viewCommands);
            mocks.ReplayAll();

            using (var plugin = new RiskeerPlugin())
            {
                plugin.Gui = gui;

                var context = new TestStateRootContext(assessmentSection);

                PropertyInfo info = GetInfo(plugin);

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

                // Assert
                Assert.IsInstanceOf <AssessmentSectionProperties>(objectProperties);
                Assert.AreSame(assessmentSection, objectProperties.Data);
            }

            mocks.VerifyAll();
        }
        public void CreateInstance_WithContext_SetsDataCorrectly()
        {
            // Setup
            var mockRepository    = new MockRepository();
            var assessmentSection = mockRepository.Stub <IAssessmentSection>();

            mockRepository.ReplayAll();

            var hydraulicBoundaryLocationCalculations = new ObservableList <HydraulicBoundaryLocationCalculation>();

            double GetNormFunc() => 0.01;

            var context = new WaterLevelCalculationsForNormTargetProbabilityContext(hydraulicBoundaryLocationCalculations,
                                                                                    assessmentSection,
                                                                                    GetNormFunc);

            using (var plugin = new RiskeerPlugin())
            {
                PropertyInfo info = GetInfo(plugin);

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

                // Assert
                Assert.IsInstanceOf <WaterLevelCalculationsForNormTargetProbabilityProperties>(objectProperties);
                Assert.AreSame(hydraulicBoundaryLocationCalculations, objectProperties.Data);
                Assert.AreEqual(GetNormFunc(), ((WaterLevelCalculationsForNormTargetProbabilityProperties)objectProperties).TargetProbability);
            }

            mockRepository.VerifyAll();
        }
        public void CreateInstance_ValidData_NewPropertiesWithOutputAsData()
        {
            // Setup
            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            var mocks = new MockRepository();
            IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);

            mocks.ReplayAll();

            var scenario = new MacroStabilityInwardsCalculationScenario
            {
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            };

            var context = new MacroStabilityInwardsOutputContext(scenario, failureMechanism, assessmentSection);

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

            // Assert
            Assert.IsInstanceOf <MacroStabilityInwardsOutputProperties>(objectProperties);
            Assert.AreSame(scenario.Output, objectProperties.Data);
            mocks.VerifyAll();
        }
        public void CreateInstance_WithContext_SetsFailureMechanismAsData()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
            var context          = new WaveImpactAsphaltCoverFailureMechanismContext(failureMechanism, assessmentSection);

            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                PropertyInfo info = GetInfo(plugin);

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

                // Assert
                Assert.IsInstanceOf <WaveImpactAsphaltCoverFailureMechanismProperties>(objectProperties);
                Assert.AreSame(failureMechanism, objectProperties.Data);
            }

            mocks.VerifyAll();
        }
        public void CreateInstance_ValidBackgroundData_ReturnBackgroundDataProperties(BackgroundData backgroundData)
        {
            // Call
            IObjectProperties objectProperties = info.CreateInstance(backgroundData);

            // Assert
            Assert.IsInstanceOf <BackgroundDataProperties>(objectProperties);
            Assert.AreSame(backgroundData, objectProperties.Data);
        }
 public static void ClearAll()
 {
     AssemblyInspector = null;
     Connection        = null;
     DataPopulation    = null;
     DataType          = null;
     DataSave          = null;
     ObjectProperties  = null;
     ClassProperties   = null;
 }
Exemplo n.º 12
0
		public static void ClearAll()
		{
			AssemblyInspector = null;
			Connection = null;
			DataPopulation = null;
			DataType = null;
			DataSave = null;
			ObjectProperties = null;
			ClassProperties = null;

		}
Exemplo n.º 13
0
        public void CreateInstance_ValidArguments_ReturnProperties()
        {
            // Setup
            var context = new AssessmentSectionAssemblyGroupsContext(new AssessmentSection(AssessmentSectionComposition.Dike));

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

            // Assert
            Assert.IsInstanceOf <AssessmentSectionAssemblyGroupsProperties>(objectProperties);
            Assert.AreSame(context.WrappedData, objectProperties.Data);
        }
        public void CreateInstance_WithStochasticSoilModel_NewPropertiesWithInputAsData()
        {
            // Setup
            PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel();

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

            // Assert
            Assert.IsInstanceOf <PipingStochasticSoilModelProperties>(objectProperties);
            Assert.AreSame(stochasticSoilModel, objectProperties.Data);
        }
        public void CreateInstance_WithStochasticSoilProfile_NewPropertiesWithInputAsData()
        {
            // Setup
            var stochasticSoilProfile = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile());

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

            // Assert
            Assert.IsInstanceOf <PipingStochasticSoilProfileProperties>(objectProperties);
            Assert.AreSame(stochasticSoilProfile, objectProperties.Data);
        }
        public void CreateInstance_WithValidArguments_NewPropertiesWithMapLineDataAsData()
        {
            // Setup
            var mapData = new MapLineData("Test");
            var context = new MapLineDataContext(mapData, new MapDataCollectionContext(new MapDataCollection("test"), null));

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

            // Assert
            Assert.IsInstanceOf <MapLineDataProperties>(objectProperties);
            Assert.AreSame(mapData, objectProperties.Data);
        }
        public void CreateInstance_WithContext_NewPropertiesWithInputContextAsData()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilModel context =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel();

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

            // Assert
            Assert.IsInstanceOf <MacroStabilityInwardsStochasticSoilModelProperties>(objectProperties);
            Assert.AreSame(context, objectProperties.Data);
        }
        public void CreateInstance_ValidArguments_ReturnFaultTreeIllustrationPointBaseProperties()
        {
            // Setup
            var illustrationPoint     = new TestSubMechanismIllustrationPoint();
            var illustrationPointNode = new IllustrationPointNode(illustrationPoint);
            var context = new IllustrationPointContext <SubMechanismIllustrationPoint>(illustrationPoint, illustrationPointNode,
                                                                                       "Wind direction", "Closing situation");

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

            // Assert
            Assert.IsInstanceOf <SubMechanismIllustrationPointProperties>(objectProperties);
            Assert.AreSame(illustrationPoint, objectProperties.Data);
        }
        public void CreateInstance_StructuresOutputContext_ReturnStructuresOutputProperties()
        {
            // Setup
            var calculation = new TestStructuresCalculationScenario
            {
                Output = new StructuresOutput(0, null)
            };

            // Call
            IObjectProperties objectProperties = info.CreateInstance(new StructuresOutputContext(calculation));

            // Assert
            Assert.IsInstanceOf <ObjectProperties <StructuresOutput> >(objectProperties);
            Assert.AreSame(calculation.Output, objectProperties.Data);
        }
Exemplo n.º 20
0
        private static object CreateObjectProperties(PropertyInfo propertyInfo, object sourceData)
        {
            try
            {
                // Try to create object properties for the source data
                IObjectProperties objectProperties = propertyInfo.CreateInstance(sourceData);

                // Return a dynamic property bag containing the created object properties
                return(new DynamicPropertyBag(objectProperties));
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemplo n.º 21
0
        public void CreateInstance_WithContext_NewPropertiesWithData()
        {
            // Setup
            var overtoppingOutput = new TestOvertoppingOutput(0.5);
            var calculation       = new GrassCoverErosionInwardsCalculation
            {
                Output = new GrassCoverErosionInwardsOutput(overtoppingOutput, null, null)
            };

            // Call
            IObjectProperties objectProperties = info.CreateInstance(new OvertoppingOutputContext(calculation));

            // Assert
            Assert.IsInstanceOf <OvertoppingOutputProperties>(objectProperties);
            Assert.AreSame(overtoppingOutput, objectProperties.Data);
        }
        public void CreateInstance_WithDuneLocationCalculation_SetsDuneLocationCalculationAsData()
        {
            // Setup
            var duneLocationCalculation = new DuneLocationCalculation(new TestDuneLocation());

            using (var plugin = new DuneErosionPlugin())
            {
                PropertyInfo info = GetInfo(plugin);

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

                // Assert
                Assert.IsInstanceOf <DuneLocationCalculationProperties>(objectProperties);
                Assert.AreSame(duneLocationCalculation, objectProperties.Data);
            }
        }
        public void CreateInstance_SelectedTopLevelSubMechanismIllustrationPoint_ReturnsTopLevelSubMechanismIllustrationPointProperties()
        {
            // Setup
            var topLevelSubMechanismIllustrationPoint = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(),
                                                                                                  string.Empty,
                                                                                                  new TestSubMechanismIllustrationPoint());

            var selectedTopLevelSubMechanismIllustrationPoint = new SelectedTopLevelSubMechanismIllustrationPoint(topLevelSubMechanismIllustrationPoint,
                                                                                                                  Enumerable.Empty <string>());

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

            // Assert
            Assert.IsInstanceOf <TopLevelSubMechanismIllustrationPointProperties>(objectProperties);
            Assert.AreSame(topLevelSubMechanismIllustrationPoint, objectProperties.Data);
        }
        public void CreateInstance_WithContextWithOtherPartialOutput_Null()
        {
            // Setup
            var calculation = new ProbabilisticPipingCalculationScenario
            {
                Output = new ProbabilisticPipingOutput(PipingTestDataGenerator.GetRandomPartialProbabilisticPipingOutput(),
                                                       PipingTestDataGenerator.GetRandomPartialProbabilisticPipingOutput())
            };

            var context = new ProbabilisticPipingSectionSpecificOutputContext(calculation);

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

            // Assert
            Assert.IsNull(objectProperties);
        }
        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);
        }
Exemplo n.º 26
0
        public void CreateInstance_WithContext_ReturnReferenceLineProperties()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new ReferenceLineContext(new ReferenceLine(), assessmentSection);

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

            // Assert
            Assert.IsInstanceOf <ReferenceLineProperties>(objectProperties);
            Assert.AreSame(context.WrappedData, objectProperties.Data);
            mocks.VerifyAll();
        }
        public void CreateInstance_WithContextWithPartialSubMechanismOutput_ExpectedProperties()
        {
            // Setup
            var calculation = new ProbabilisticPipingCalculationScenario
            {
                Output = new ProbabilisticPipingOutput(PipingTestDataGenerator.GetRandomPartialProbabilisticSubMechanismPipingOutput(),
                                                       PipingTestDataGenerator.GetRandomPartialProbabilisticSubMechanismPipingOutput())
            };

            var context = new ProbabilisticPipingSectionSpecificOutputContext(calculation);

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

            // Assert
            Assert.IsInstanceOf <ProbabilisticSubMechanismPipingOutputProperties>(objectProperties);
            Assert.AreSame(context.WrappedData.Output.SectionSpecificOutput, objectProperties.Data);
        }
Exemplo n.º 28
0
        public void CreateInstance_TopLevelFaultTreeIllustrationPoint_ReturnFaultTreeIllustrationPointBaseProperties()
        {
            // Setup
            var topLevelFaultTreeIllustrationPoint = new TopLevelFaultTreeIllustrationPoint(
                WindDirectionTestFactory.CreateTestWindDirection(),
                "Closing situation",
                new IllustrationPointNode(new TestIllustrationPoint()));

            var selectedTopLevelFaultTreeIllustrationPoint = new SelectedTopLevelFaultTreeIllustrationPoint(topLevelFaultTreeIllustrationPoint,
                                                                                                            Enumerable.Empty <string>());

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

            // Assert
            Assert.IsInstanceOf <TopLevelFaultTreeIllustrationPointProperties>(objectProperties);
            Assert.AreSame(topLevelFaultTreeIllustrationPoint, objectProperties.Data);
        }
Exemplo n.º 29
0
        public void CreateInstance_WithValidArguments_NewPropertiesWithFailureMechanismAsData()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var failureMechanismSectionsContext = new PipingFailureMechanismSectionsContext(new PipingFailureMechanism(),
                                                                                            assessmentSection);

            mocks.ReplayAll();

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

            // Assert
            Assert.IsInstanceOf <FailureMechanismSectionsProbabilityAssessmentProperties>(objectProperties);
            Assert.AreSame(failureMechanismSectionsContext.WrappedData, objectProperties.Data);
            mocks.VerifyAll();
        }
        public void CreateInstance_WithContext_SetsOutputAsData()
        {
            // Setup
            StabilityStoneCoverWaveConditionsOutput output = StabilityStoneCoverWaveConditionsOutputTestFactory.Create();
            var context = new StabilityStoneCoverWaveConditionsOutputContext(output, new StabilityStoneCoverWaveConditionsInput());

            using (var plugin = new StabilityStoneCoverPlugin())
            {
                PropertyInfo info = GetInfo(plugin);

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

                // Assert
                Assert.IsInstanceOf <StabilityStoneCoverWaveConditionsOutputProperties>(objectProperties);
                Assert.AreSame(output, objectProperties.Data);
            }
        }
        public void CreateInstance_WithContext_NewPropertiesWithFailureMechanismAsData()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var failureMechanism  = mocks.Stub <IHasGeneralInput>();

            mocks.ReplayAll();

            var context = new TestFailureMechanismContext(failureMechanism, assessmentSection);

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

            // Assert
            Assert.IsInstanceOf <StandAloneFailureMechanismProperties>(objectProperties);
            Assert.AreSame(failureMechanism, objectProperties.Data);
            mocks.VerifyAll();
        }