public void Read_EntityWithStochasticSoilModelEntityInCollector_CalculationHasAlreadyReadStochasticSoilModel()
        {
            // Setup
            PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel();
            var stochasticSoilModelEntity = new StochasticSoilModelEntity();

            var stochasticSoilProfile       = new PipingStochasticSoilProfile(1, PipingSoilProfileTestFactory.CreatePipingSoilProfile());
            var stochasticSoilProfileEntity = new PipingStochasticSoilProfileEntity
            {
                StochasticSoilModelEntity = stochasticSoilModelEntity
            };

            var entity = new SemiProbabilisticPipingCalculationEntity
            {
                PipingStochasticSoilProfileEntity = stochasticSoilProfileEntity,
                EntryPointL           = 1,
                ExitPointL            = 2,
                DampingFactorExitMean = 1,
                ScenarioContribution  = 0
            };

            var collector = new ReadConversionCollector();

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

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

            // Assert
            Assert.AreSame(stochasticSoilProfile, calculation.InputParameters.StochasticSoilProfile);
            Assert.AreSame(stochasticSoilModel, calculation.InputParameters.StochasticSoilModel);
        }
コード例 #2
0
        public void Update_ModelsWithAddedProfilesWithSameNames_ThrowsInvalidOperationException()
        {
            // Setup
            const string profileName             = "Name of the profile";
            var          addedProfile            = new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile(profileName));
            PipingStochasticSoilModel otherModel = CreateValidModel(new[]
            {
                addedProfile
            });

            PipingSoilProfile soilProfile        = PipingSoilProfileTestFactory.CreatePipingSoilProfile(profileName);
            var existingStochasticSoilProfileOne = new PipingStochasticSoilProfile(0.2, soilProfile);
            var existingStochasticSoilProfileTwo = new PipingStochasticSoilProfile(0.3, soilProfile);
            PipingStochasticSoilModel model      = CreateValidModel(new[]
            {
                existingStochasticSoilProfileOne,
                existingStochasticSoilProfileTwo
            });

            // Call
            TestDelegate call = () => model.Update(otherModel);

            // Assert
            Assert.Throws <InvalidOperationException>(call);

            Assert.AreEqual(1, otherModel.StochasticSoilProfiles.Count());
            Assert.AreEqual(addedProfile, otherModel.StochasticSoilProfiles.First());

            Assert.AreEqual(2, model.StochasticSoilProfiles.Count());
            CollectionAssert.AreEqual(new[]
            {
                existingStochasticSoilProfileOne,
                existingStochasticSoilProfileTwo
            }, model.StochasticSoilProfiles);
        }
コード例 #3
0
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("Name", new[]
            {
                new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile()),
                new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile())
            });

            var failureMechanism = new PipingFailureMechanism();
            var stochasticSoilModelCollectionContext = new PipingStochasticSoilModelCollectionContext(
                failureMechanism.StochasticSoilModels,
                failureMechanism,
                assessmentSection);

            failureMechanism.StochasticSoilModels.AddRange(new[]
            {
                stochasticSoilModel
            }, "path");

            // Call
            object[] objects = info.ChildNodeObjects(stochasticSoilModelCollectionContext);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                stochasticSoilModel
            }, objects);
        }
コード例 #4
0
            private static PipingStochasticSoilProfile CreateStochasticSoilProfile()
            {
                var random = new Random(21);

                return(new PipingStochasticSoilProfile(random.NextDouble(),
                                                       PipingSoilProfileTestFactory.CreatePipingSoilProfile("Name")));
            }
コード例 #5
0
        /// <summary>
        /// This method sets random data values to all properties of <paramref name="input"/>.
        /// </summary>
        /// <param name="input">The input to set the random data values to.</param>
        public static void SetRandomDataToPipingInput(PipingInput input)
        {
            var random = new Random(21);

            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(random.Next(0, 5), random.Next(0, 5), random.Next(0, 5)),
                new Point3D(random.Next(5, 10), random.Next(5, 10), random.Next(5, 10))
            });

            input.EntryPointL           = random.NextRoundedDouble();
            input.ExitPointL            = random.NextRoundedDouble();
            input.SurfaceLine           = surfaceLine;
            input.StochasticSoilModel   = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("model");
            input.StochasticSoilProfile = new PipingStochasticSoilProfile(random.NextDouble(),
                                                                          PipingSoilProfileTestFactory.CreatePipingSoilProfile());
            input.HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
            input.PhreaticLevelExit         = new NormalDistribution
            {
                Mean = random.NextRoundedDouble(),
                StandardDeviation = random.NextRoundedDouble()
            };
            input.DampingFactorExit = new LogNormalDistribution
            {
                Mean = random.NextRoundedDouble(),
                StandardDeviation = random.NextRoundedDouble()
            };
        }
コード例 #6
0
        public void Create_StochasticSoilProfileSet_EntityHasStochasticSoilProfileEntity()
        {
            // Setup
            PipingSoilProfile soilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();
            var stochasticSoilProfile     = new PipingStochasticSoilProfile(0.6, soilProfile);

            PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A", new[]
            {
                stochasticSoilProfile
            });

            var registry = new PersistenceRegistry();
            StochasticSoilModelEntity soilModelEntity = soilModel.Create(registry, 0);

            var calculation = new ProbabilisticPipingCalculationScenario
            {
                InputParameters =
                {
                    StochasticSoilModel   = soilModel,
                    StochasticSoilProfile = stochasticSoilProfile
                }
            };

            // Call
            ProbabilisticPipingCalculationEntity entity = calculation.Create(registry, 0);

            // Assert
            PipingStochasticSoilProfileEntity expectedStochasticSoilProfileEntity = soilModelEntity.PipingStochasticSoilProfileEntities.First();

            Assert.AreSame(expectedStochasticSoilProfileEntity, entity.PipingStochasticSoilProfileEntity);
            Assert.IsTrue(registry.Contains(soilModel));
        }
        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 hasStochasticSoilProfile = mockRepository.Stub <IHasStochasticSoilProfile>();
            var stochasticSoilProfile    = new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile());

            hasStochasticSoilProfile.Stub(hssp => hssp.StochasticSoilProfile).Return(stochasticSoilProfile);
            hasStochasticSoilProfile.Stub(hssp => hssp.GetAvailableStochasticSoilProfiles()).Return(
                new[]
            {
                stochasticSoilProfile
            });

            var editor      = new PipingInputContextStochasticSoilProfileSelectionEditor <IHasStochasticSoilProfile>();
            var someValue   = new object();
            var propertyBag = new DynamicPropertyBag(hasStochasticSoilProfile);

            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();
        }
コード例 #8
0
 /// <summary>
 /// Creates a new instance of <see cref="PipingStochasticSoilModel"/>.
 /// </summary>
 /// <param name="name">The name of the stochastic soil model.</param>
 /// <param name="geometry">The geometry of the stochastic soil model.</param>
 /// <returns>A valid instance of <see cref="PipingStochasticSoilModel"/>.</returns>
 /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Thrown when <paramref name="geometry"/> is empty.</exception>
 public static PipingStochasticSoilModel CreatePipingStochasticSoilModel(string name, IEnumerable <Point2D> geometry)
 {
     return(new PipingStochasticSoilModel(name, geometry, new[]
     {
         new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("A")),
         new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("B"))
     }));
 }
コード例 #9
0
        public void Update_WithOtherModel_PropertiesUpdated()
        {
            // Setup
            const string equalProfileName   = "nameA";
            var          stochasticProfileA = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile(equalProfileName));
            var          stochasticProfileB = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("nameB"));
            PipingStochasticSoilModel model = CreateValidModel(new[]
            {
                stochasticProfileA,
                stochasticProfileB
            });

            const string otherName     = "other name";
            var          otherGeometry = new[]
            {
                new Point2D(2, 0),
                new Point2D(3, 0)
            };
            var otherStochasticProfileA = new PipingStochasticSoilProfile(
                0.7, new PipingSoilProfile(equalProfileName, -1, new[]
            {
                new PipingSoilLayer(0)
            }, SoilProfileType.SoilProfile1D));
            var otherStochasticProfileB = new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile("other profile name"));
            var otherModel = new PipingStochasticSoilModel(otherName, otherGeometry, new[]
            {
                otherStochasticProfileA,
                otherStochasticProfileB
            });

            // Call
            PipingStochasticSoilModelProfileDifference difference = model.Update(otherModel);

            // Assert
            Assert.AreEqual(otherName, model.Name);
            Assert.AreSame(otherGeometry, model.Geometry);

            PipingStochasticSoilProfile[] stochasticSoilProfiles = model.StochasticSoilProfiles.ToArray();
            Assert.AreEqual(2, stochasticSoilProfiles.Length);
            Assert.AreSame(stochasticProfileA, stochasticSoilProfiles[0]);
            Assert.AreSame(otherStochasticProfileA.SoilProfile, stochasticSoilProfiles[0].SoilProfile);
            Assert.AreNotSame(stochasticProfileB, stochasticSoilProfiles[1]);
            Assert.AreSame(otherStochasticProfileB.SoilProfile, stochasticSoilProfiles[1].SoilProfile);

            CollectionAssert.AreEqual(new[]
            {
                stochasticProfileA
            }, difference.UpdatedProfiles);
            CollectionAssert.AreEqual(new[]
            {
                stochasticProfileB
            }, difference.RemovedProfiles);
            CollectionAssert.AreEqual(new[]
            {
                otherStochasticProfileB
            }, difference.AddedProfiles);
        }
コード例 #10
0
        public void StochasticSoilProfile_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            var newProfile = new PipingStochasticSoilProfile(0, PipingSoilProfileTestFactory.CreatePipingSoilProfile());
            var newValue   = new DataGridViewComboBoxItemWrapper <PipingStochasticSoilProfile>(newProfile);

            var calculation = new TestPipingCalculationScenario();

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.StochasticSoilProfile = newValue, calculation);
        }
コード例 #11
0
            private static IEnumerable <TestCaseData> GetUnequalTestCases()
            {
                PipingStochasticSoilProfile baseProfile = CreateStochasticSoilProfile();

                yield return(new TestCaseData(new PipingStochasticSoilProfile(0.5,
                                                                              baseProfile.SoilProfile))
                             .SetName("Probability"));

                yield return(new TestCaseData(new PipingStochasticSoilProfile(baseProfile.Probability,
                                                                              PipingSoilProfileTestFactory.CreatePipingSoilProfile("Different Name")))
                             .SetName("SoilProfile"));
            }
コード例 #12
0
        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);
        }
コード例 #13
0
        public void Update_SoilProfileNull_ThrowsArgumentNullException()
        {
            // Setup
            var stochasticProfile = new PipingStochasticSoilProfile(0.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile());

            // Call
            void Call() => stochasticProfile.Update(null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("fromProfile", exception.ParamName);
        }
コード例 #14
0
        public void Constructor_WithInvalidProbabilities_ThrowsArgumentOutOfRangeException(double probability)
        {
            // Setup
            PipingSoilProfile profile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();

            // Call
            void Call() => new PipingStochasticSoilProfile(probability, profile);

            // Assert
            const string expectedMessage = "Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel moet in het bereik [0,0, 1,0] liggen.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(Call, expectedMessage);
        }
コード例 #15
0
        /// <summary>
        /// Creates a simple model with names for the model and profiles in the model set as specified.
        /// </summary>
        /// <param name="modelName">Name of the created model.</param>
        /// <param name="profileNames">List of names for the profiles to be added to the model.</param>
        /// <returns>A new <see cref="PipingStochasticSoilModel"/>.</returns>
        private static PipingStochasticSoilModel CreateSimpleModel(string modelName, params string[] profileNames)
        {
            var stochasticProfiles = new List <PipingStochasticSoilProfile>();

            foreach (string profileName in profileNames)
            {
                stochasticProfiles.Add(new PipingStochasticSoilProfile(
                                           1.0 / profileNames.Length,
                                           PipingSoilProfileTestFactory.CreatePipingSoilProfile(profileName)));
            }

            return(PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(modelName, stochasticProfiles));
        }
コード例 #16
0
        public void ClearStochasticSoilProfileDependentData_WithoutFailureMechanism_ThrowsArgumentNullException()
        {
            // Setup
            var stochasticSoilProfile = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile());

            // Call
            void Call() => PipingDataSynchronizationService.ClearStochasticSoilProfileDependentData(null, stochasticSoilProfile);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("failureMechanism", exception.ParamName);
        }
コード例 #17
0
        public void Text_WithStochasticSoilProfile_ReturnsSoilProfileName()
        {
            // Setup
            const string testName = "ttt";
            var          stochasticSoilProfile = new PipingStochasticSoilProfile(0.1,
                                                                                 PipingSoilProfileTestFactory.CreatePipingSoilProfile(testName));

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

            // Assert
            Assert.AreEqual(testName, text);
        }
コード例 #18
0
        public void Transform_StochasticSoilProfileNull_ThrowsArgumentNullException()
        {
            // Setup
            PipingSoilProfile soilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();

            // Call
            TestDelegate test = () => PipingStochasticSoilProfileTransformer.Transform(null, soilProfile);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(test);

            Assert.AreEqual("stochasticSoilProfile", exception.ParamName);
        }
コード例 #19
0
        public void Create_PersistenceRegistryNull_ThrowsArgumentNullException()
        {
            // Setup
            PipingSoilProfile soilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();

            // Call
            TestDelegate test = () => soilProfile.Create(null);

            // Assert
            string parameterName = Assert.Throws <ArgumentNullException>(test).ParamName;

            Assert.AreEqual("registry", parameterName);
        }
        public void Create_SamePipingStochasticSoilProfileMultipleTimes_ReturnSameEntity()
        {
            // Setup
            PipingSoilProfile soilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();
            var stochasticSoilProfile     = new PipingStochasticSoilProfile(0.4, soilProfile);
            var registry = new PersistenceRegistry();

            // Call
            PipingStochasticSoilProfileEntity entity1 = stochasticSoilProfile.Create(registry, 0);
            PipingStochasticSoilProfileEntity entity2 = stochasticSoilProfile.Create(registry, 0);

            // Assert
            Assert.AreSame(entity1, entity2);
        }
コード例 #21
0
        public void Create_ForTheSameEntityTwice_ReturnsSamePipingSoilProfileEntityInstance()
        {
            // Setup
            PipingSoilProfile soilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();
            var registry = new PersistenceRegistry();

            PipingSoilProfileEntity firstEntity = soilProfile.Create(registry);

            // Call
            PipingSoilProfileEntity secondEntity = soilProfile.Create(registry);

            // Assert
            Assert.AreSame(firstEntity, secondEntity);
        }
コード例 #22
0
        public void Constructor_WithValidProbabilities_ExpectedValues(double probability)
        {
            // Setup
            PipingSoilProfile profile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();

            // Call
            var stochasticSoilProfile = new PipingStochasticSoilProfile(probability, profile);

            // Assert
            Assert.IsInstanceOf <Observable>(stochasticSoilProfile);
            Assert.AreEqual(probability, stochasticSoilProfile.Probability);
            Assert.AreSame(profile, stochasticSoilProfile.SoilProfile);
            Assert.AreEqual(profile.ToString(), stochasticSoilProfile.ToString());
        }
        public void Create_DifferentStochasticSoilProfilesWithSamePipingSoilProfile_ReturnsPipingStochasticSoilProfileEntityWithSameSoilProfileEntitySet()
        {
            // Setup
            PipingSoilProfile testPipingSoilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();
            var firstStochasticSoilProfile          = new PipingStochasticSoilProfile(new Random(21).NextDouble(), testPipingSoilProfile);
            var secondStochasticSoilProfile         = new PipingStochasticSoilProfile(new Random(21).NextDouble(), testPipingSoilProfile);
            var registry = new PersistenceRegistry();

            // Call
            PipingStochasticSoilProfileEntity firstEntity  = firstStochasticSoilProfile.Create(registry, 0);
            PipingStochasticSoilProfileEntity secondEntity = secondStochasticSoilProfile.Create(registry, 0);

            // Assert
            Assert.AreSame(firstEntity.PipingSoilProfileEntity, secondEntity.PipingSoilProfileEntity);
        }
コード例 #24
0
        public void Constructor_ValidStochasticSoilProfile_ExpectedValues()
        {
            // Setup
            var stochasticSoilProfile = new PipingStochasticSoilProfile(1, PipingSoilProfileTestFactory.CreatePipingSoilProfile());

            // Call
            var properties = new PipingStochasticSoilProfileProperties(stochasticSoilProfile);

            // Assert
            Assert.IsInstanceOf <ObjectProperties <PipingStochasticSoilProfile> >(properties);
            TestHelper.AssertTypeConverter <PipingStochasticSoilProfileProperties,
                                            ExpandableArrayConverter>(nameof(PipingStochasticSoilProfileProperties.Layers));
            TestHelper.AssertTypeConverter <PipingStochasticSoilProfileProperties,
                                            EnumTypeConverter>(nameof(PipingStochasticSoilProfileProperties.Type));
            Assert.AreSame(stochasticSoilProfile, properties.Data);
        }
コード例 #25
0
        public void SyncStochasticSoilProfileWithStochasticSoilModel_MultipleStochasticSoilProfilesInStochasticSoilModel_DoesNotSetStochasticSoilProfile()
        {
            // Setup
            PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(new[]
            {
                new PipingStochasticSoilProfile(0.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()),
                new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile())
            });

            var pipingInput = new TestPipingInput
            {
                StochasticSoilModel = soilModel
            };

            // Call
            PipingInputService.SyncStochasticSoilProfileWithStochasticSoilModel(pipingInput);

            // Assert
            Assert.IsNull(pipingInput.StochasticSoilProfile);
        }
コード例 #26
0
        public void SyncStochasticSoilProfileWithStochasticSoilModel_SingleStochasticSoilProfileInSoilModelAlreadySet_StochasticSoilProfileDoesNotChange()
        {
            // Setup
            var soilProfile = new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile());
            PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(new[]
            {
                soilProfile
            });

            var pipingInput = new TestPipingInput
            {
                StochasticSoilModel   = soilModel,
                StochasticSoilProfile = soilProfile
            };

            // Call
            PipingInputService.SyncStochasticSoilProfileWithStochasticSoilModel(pipingInput);

            // Assert
            Assert.AreEqual(soilProfile, pipingInput.StochasticSoilProfile);
        }
コード例 #27
0
        public void SyncStochasticSoilProfileWithStochasticSoilModel_SingleStochasticSoilProfileInStochasticSoilModel_SetsStochasticSoilProfile()
        {
            // Setup
            var soilProfile = new PipingStochasticSoilProfile(1, PipingSoilProfileTestFactory.CreatePipingSoilProfile());

            PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A", new[]
            {
                soilProfile
            });

            var pipingInput = new TestPipingInput
            {
                StochasticSoilModel = soilModel
            };

            // Call
            PipingInputService.SyncStochasticSoilProfileWithStochasticSoilModel(pipingInput);

            // Assert
            Assert.AreSame(soilProfile, pipingInput.StochasticSoilProfile);
        }
コード例 #28
0
        public void GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            var stochasticSoilModel = new PipingStochasticSoilModel("Name", new[]
            {
                new Point2D(1.0, 2.0)
            }, new[]
            {
                new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile())
            });

            // Call
            var properties = new PipingStochasticSoilModelProperties(stochasticSoilModel);

            // Assert
            Assert.AreEqual(stochasticSoilModel.Name, properties.Name);
            CollectionAssert.AreEqual(stochasticSoilModel.Geometry, properties.Geometry);

            PipingStochasticSoilProfile[] stochasticSoilProfiles = stochasticSoilModel.StochasticSoilProfiles.ToArray();
            Assert.AreEqual(stochasticSoilProfiles.Length, properties.StochasticSoilProfiles.Length);
            Assert.AreSame(stochasticSoilProfiles[0], properties.StochasticSoilProfiles[0].Data);
        }
コード例 #29
0
        private static TestCaseData[] PipingStochasticProfileUnequalCombinations()
        {
            const string profileName            = "newProfile";
            var          stochasticSoilProfileA = new PipingStochasticSoilProfile(
                1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile(profileName));
            var stochasticSoilProfileB = new PipingStochasticSoilProfile(
                0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile(profileName));
            var stochasticSoilProfileC = new PipingStochasticSoilProfile(
                1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile(profileName, SoilProfileType.SoilProfile2D));

            return(new[]
            {
                new TestCaseData(stochasticSoilProfileA, stochasticSoilProfileB)
                {
                    TestName = "Update_ProfileWithProfileA_UpdatesProperties"
                },
                new TestCaseData(stochasticSoilProfileA, stochasticSoilProfileC)
                {
                    TestName = "Update_ProfileWithProfileB_UpdatesProperties"
                }
            });
        }
コード例 #30
0
        public void Transform_ValidStochasticSoilProfile_ReturnsExpectedPipingStochasticSoilProfile()
        {
            // Setup
            var random = new Random(21);

            var mockRepository = new MockRepository();
            var soilProfile    = mockRepository.Stub <ISoilProfile>();

            mockRepository.ReplayAll();

            PipingSoilProfile pipingSoilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();

            var stochasticSoilProfile = new StochasticSoilProfile(random.NextDouble(), soilProfile);

            // Call
            PipingStochasticSoilProfile pipingStochasticSoilProfile = PipingStochasticSoilProfileTransformer.Transform(stochasticSoilProfile, pipingSoilProfile);

            // Assert
            Assert.AreEqual(stochasticSoilProfile.Probability, pipingStochasticSoilProfile.Probability);
            Assert.AreSame(pipingSoilProfile, pipingStochasticSoilProfile.SoilProfile);
            mockRepository.VerifyAll();
        }