public void Read_WithNullValues_ReturnsSoilProfileWithNaNValues()
        {
            // Setup
            var entity = new MacroStabilityInwardsSoilProfileOneDEntity
            {
                Name   = nameof(MacroStabilityInwardsSoilProfileOneDEntity),
                Bottom = null,
                MacroStabilityInwardsSoilLayerOneDEntities =
                {
                    new MacroStabilityInwardsSoilLayerOneDEntity
                    {
                        MaterialName = nameof(MacroStabilityInwardsSoilLayerOneDEntity)
                    }
                }
            };
            var collector = new ReadConversionCollector();

            // Call
            MacroStabilityInwardsSoilProfile1D profile = entity.Read(collector);

            // Assert
            Assert.IsNotNull(profile);
            Assert.AreEqual(entity.Name, profile.Name);
            Assert.IsNaN(profile.Bottom);
            Assert.AreEqual(entity.MacroStabilityInwardsSoilLayerOneDEntities.Count, profile.Layers.Count());

            MacroStabilityInwardsSoilLayer1D layer = profile.Layers.ElementAt(0);

            Assert.AreEqual(entity.MacroStabilityInwardsSoilLayerOneDEntities.First().MaterialName, layer.Data.MaterialName);
        }
        public void GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            var soilProfile = new MacroStabilityInwardsSoilProfile1D("MacroStabilityInwardsSoilProfile", 0, new List <MacroStabilityInwardsSoilLayer1D>
            {
                new MacroStabilityInwardsSoilLayer1D(10)
            });
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(1.0, soilProfile);
            var stochasticSoilModel   = new MacroStabilityInwardsStochasticSoilModel("name", new[]
            {
                new Point2D(1.0, 2.0)
            }, new[]
            {
                stochasticSoilProfile
            });

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

            // Assert
            Assert.AreEqual(stochasticSoilModel.Name, properties.Name);
            CollectionAssert.AreEqual(stochasticSoilModel.Geometry, properties.Geometry);
            Assert.AreEqual(1, properties.MacroStabilityInwardsStochasticSoilProfiles.Length);
            Assert.AreSame(stochasticSoilProfile, properties.MacroStabilityInwardsStochasticSoilProfiles[0].Data);
        }
示例#3
0
        public void Update_ModelWithRemovedProfileSameNameOtherType_ProfileRemoved()
        {
            // Setup
            const string profileName            = "A";
            var          soilProfile            = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers1D());
            var          expectedRemovedProfile = new MacroStabilityInwardsStochasticSoilProfile(0.2, soilProfile);
            var          newProfile             = new MacroStabilityInwardsStochasticSoilProfile(
                0.2,
                new MacroStabilityInwardsSoilProfile2D(profileName, CreateLayers2D(), Enumerable.Empty <MacroStabilityInwardsPreconsolidationStress>()));
            MacroStabilityInwardsStochasticSoilModel model = CreateValidModel(new[]
            {
                expectedRemovedProfile
            });

            MacroStabilityInwardsStochasticSoilModel otherModel = CreateValidModel(new[]
            {
                newProfile
            });

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

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                newProfile
            }, difference.AddedProfiles);
            CollectionAssert.IsEmpty(difference.UpdatedProfiles);
            CollectionAssert.AreEqual(new[]
            {
                expectedRemovedProfile
            }, difference.RemovedProfiles);
        }
        public void SoilProfile1DCreate_ValidSoilProfile1D_ReturnsEmptyPreconsolidationStresses()
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 4.0),
                new Point3D(4, 0, 0.0),
                new Point3D(8, 0, 4.0)
            });

            var layer   = new MacroStabilityInwardsSoilLayer1D(1);
            var profile = new MacroStabilityInwardsSoilProfile1D("name", 0, new[]
            {
                layer
            });

            // Call
            MacroStabilityInwardsSoilProfileUnderSurfaceLine profileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(
                profile, surfaceLine);

            // Assert
            CollectionAssert.IsEmpty(profileUnderSurfaceLine.PreconsolidationStresses);
        }
示例#5
0
        /// <summary>
        /// Reads the <see cref="MacroStabilityInwardsSoilProfileOneDEntity"/> and use the information
        /// to construct a <see cref="MacroStabilityInwardsSoilProfile1D"/>.
        /// </summary>
        /// <param name="entity">The <see cref="MacroStabilityInwardsSoilProfileOneDEntity"/> to
        /// create <see cref="MacroStabilityInwardsSoilProfile1D"/> for.</param>
        /// <param name="collector">The object keeping track of read operations.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsSoilProfile1D"/> or one from the <paramref name="collector"/>
        /// if the <see cref="MacroStabilityInwardsSoilProfileOneDEntity"/> has been read before.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public static MacroStabilityInwardsSoilProfile1D Read(this MacroStabilityInwardsSoilProfileOneDEntity entity,
                                                              ReadConversionCollector collector)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            if (collector == null)
            {
                throw new ArgumentNullException(nameof(collector));
            }

            if (collector.Contains(entity))
            {
                return(collector.Get(entity));
            }

            IEnumerable <MacroStabilityInwardsSoilLayer1D> layers = entity.MacroStabilityInwardsSoilLayerOneDEntities.OrderBy(sl => sl.Order)
                                                                    .Select(sl => sl.Read())
                                                                    .ToArray();
            var macroStabilityInwardsSoilProfile = new MacroStabilityInwardsSoilProfile1D(entity.Name,
                                                                                          entity.Bottom.ToNullAsNaN(),
                                                                                          layers);

            collector.Read(entity, macroStabilityInwardsSoilProfile);
            return(macroStabilityInwardsSoilProfile);
        }
示例#6
0
        public void Create_WithValidProperties_ReturnsEntityWithPropertiesSet()
        {
            // Setup
            var          random      = new Random(31);
            const string name        = "some name";
            double       bottom      = -random.NextDouble();
            var          soilProfile = new MacroStabilityInwardsSoilProfile1D(name, bottom, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(random.NextDouble()),
                new MacroStabilityInwardsSoilLayer1D(random.NextDouble())
            });
            var registry = new PersistenceRegistry();

            // Call
            MacroStabilityInwardsSoilProfileOneDEntity entity = soilProfile.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(soilProfile.Bottom, entity.Bottom);
            Assert.AreEqual(soilProfile.Layers.Count(), entity.MacroStabilityInwardsSoilLayerOneDEntities.Count);

            MacroStabilityInwardsSoilLayerOneDEntity firstLayerEntity = entity.MacroStabilityInwardsSoilLayerOneDEntities.ElementAt(0);

            Assert.AreEqual(soilProfile.Layers.ElementAt(0).Top, firstLayerEntity.Top);

            MacroStabilityInwardsSoilLayerOneDEntity secondLayerEntity = entity.MacroStabilityInwardsSoilLayerOneDEntities.ElementAt(1);

            Assert.AreEqual(soilProfile.Layers.ElementAt(1).Top, secondLayerEntity.Top);
        }
示例#7
0
        public void Update_ModelWithUpdatedStochasticSoilProfile_ProfileUpdated()
        {
            // Setup
            const string profileName                       = "A";
            var          soilProfile                       = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers1D());
            var          expectedUpdatedProfile            = new MacroStabilityInwardsStochasticSoilProfile(0.2, soilProfile);
            MacroStabilityInwardsStochasticSoilModel model = CreateValidModel(new[]
            {
                expectedUpdatedProfile
            });

            MacroStabilityInwardsStochasticSoilModel otherModel = CreateValidModel(new[]
            {
                new MacroStabilityInwardsStochasticSoilProfile(0.5, soilProfile)
            });

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

            // Assert
            CollectionAssert.IsEmpty(difference.AddedProfiles);
            CollectionAssert.AreEqual(new[]
            {
                expectedUpdatedProfile
            }, difference.UpdatedProfiles);
            CollectionAssert.IsEmpty(difference.RemovedProfiles);
        }
示例#8
0
        public void Layers_Always_ReturnsDescendingByTopOrderedList(int layerCount)
        {
            // Setup
            var          random           = new Random(21);
            const double bottom           = 0.0;
            var          equivalentLayers = new List <MacroStabilityInwardsSoilLayer1D>(layerCount);

            for (var i = 0; i < layerCount; i++)
            {
                equivalentLayers.Add(new MacroStabilityInwardsSoilLayer1D(random.NextDouble())
                {
                    Data =
                    {
                        IsAquifer = i == 0
                    }
                });
            }

            var profile = new MacroStabilityInwardsSoilProfile1D(string.Empty, bottom, equivalentLayers);

            // Call
            MacroStabilityInwardsSoilLayer1D[] result = profile.Layers.ToArray();

            // Assert
            CollectionAssert.AreEquivalent(equivalentLayers, result);
            CollectionAssert.AreEqual(equivalentLayers.OrderByDescending(l => l.Top).Select(l => l.Top), result.Select(l => l.Top));
        }
        public void SoilProfile1DCreate_SurfaceLineOnTopOrAboveSoilLayer_ReturnsSoilLayerPointsAsRectangle()
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 4),
                new Point3D(0, 0, 3.2),
                new Point3D(2, 0, 4)
            });
            var soilLayer   = new MacroStabilityInwardsSoilLayer1D(3.2);
            var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", 2.0, new[]
            {
                soilLayer
            });

            // Call
            MacroStabilityInwardsSoilProfileUnderSurfaceLine areas = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine);

            // Assert
            Assert.AreEqual(1, areas.Layers.Count());
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(2, 3.2),
                new Point2D(2, 2),
                new Point2D(0, 2),
                new Point2D(0, 3.2)
            }, areas.Layers.ElementAt(0).OuterRing.Points);
        }
示例#10
0
        public void GenerateCalculationItemsStructure_Always_CreateCalculationsWithSurfaceLineNameSoilProfileNameGeneralInputAndSemiProbabilisticInput()
        {
            // Setup
            var soilProfile1 = new MacroStabilityInwardsSoilProfile1D("Profile 1", -10.0, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(-5.0),
                new MacroStabilityInwardsSoilLayer1D(-2.0),
                new MacroStabilityInwardsSoilLayer1D(1.0)
            });
            var soilProfile2 = new MacroStabilityInwardsSoilProfile1D("Profile 2", -8.0, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(-4.0),
                new MacroStabilityInwardsSoilLayer1D(0.0),
                new MacroStabilityInwardsSoilLayer1D(4.0)
            });

            var soilModel = new MacroStabilityInwardsStochasticSoilModel("A", new[]
            {
                new Point2D(1.0, 0.0),
                new Point2D(5.0, 0.0)
            }, new[]
            {
                new MacroStabilityInwardsStochasticSoilProfile(0.3, soilProfile1),
                new MacroStabilityInwardsStochasticSoilProfile(0.7, soilProfile2)
            });

            MacroStabilityInwardsStochasticSoilModel[] availableSoilModels =
            {
                soilModel
            };

            var surfaceLine = new MacroStabilityInwardsSurfaceLine("Surface Line");

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(3.0, 5.0, 0.0),
                new Point3D(3.0, 0.0, 1.0),
                new Point3D(3.0, -5.0, 0.0)
            });

            MacroStabilityInwardsSurfaceLine[] surfaceLines =
            {
                surfaceLine
            };

            // Call
            IEnumerable <ICalculationBase> result = MacroStabilityInwardsCalculationConfigurationHelper.GenerateCalculationItemsStructure(
                surfaceLines,
                availableSoilModels).ToArray();

            // Assert
            var group = result.First(sl => sl.Name == surfaceLine.Name) as CalculationGroup;

            Assert.NotNull(group);
            var calculationInput1 = (MacroStabilityInwardsCalculationScenario)group.Children[0];
            var calculationInput2 = (MacroStabilityInwardsCalculationScenario)group.Children[1];

            Assert.AreEqual($"{surfaceLine.Name} {soilProfile1.Name}", calculationInput1.Name);
            Assert.AreEqual($"{surfaceLine.Name} {soilProfile2.Name}", calculationInput2.Name);
        }
        public void SoilProfile1DCreate_SurfaceLineEndsBelowLayerTopButAboveBottom_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine()
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 3.0),
                new Point3D(1, 0, 2.0),
                new Point3D(2, 0, 2.0)
            });
            const double bottom      = 1.5;
            const double top         = 2.5;
            var          soilLayer   = new MacroStabilityInwardsSoilLayer1D(top);
            var          soilProfile = new MacroStabilityInwardsSoilProfile1D("name", bottom, new[]
            {
                soilLayer
            });

            // Call
            MacroStabilityInwardsSoilProfileUnderSurfaceLine areas = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine);

            // Assert
            Assert.AreEqual(1, areas.Layers.Count());
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(0.5, top),
                new Point2D(1, 2.0),
                new Point2D(2, 2.0),
                new Point2D(2, bottom),
                new Point2D(0, bottom),
                new Point2D(0, top)
            }, areas.Layers.ElementAt(0).OuterRing.Points);
        }
        /// <summary>
        /// Creates a <see cref="MacroStabilityInwardsSoilProfileOneDEntity"/> based on the information
        /// of the <see cref="MacroStabilityInwardsSoilProfile1D"/>.
        /// </summary>
        /// <param name="soilProfile">The soil profile to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsSoilProfileOneDEntity"/> or one from the
        /// <paramref name="registry"/> if it was created for the <see cref="soilProfile"/> earlier.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public static MacroStabilityInwardsSoilProfileOneDEntity Create(this MacroStabilityInwardsSoilProfile1D soilProfile,
                                                                        PersistenceRegistry registry)
        {
            if (soilProfile == null)
            {
                throw new ArgumentNullException(nameof(soilProfile));
            }

            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (registry.Contains(soilProfile))
            {
                return(registry.Get(soilProfile));
            }

            var entity = new MacroStabilityInwardsSoilProfileOneDEntity
            {
                Name   = soilProfile.Name.DeepClone(),
                Bottom = soilProfile.Bottom.ToNaNAsNull()
            };

            AddEntitiesForSoilLayers(soilProfile.Layers, entity);

            registry.Register(entity, soilProfile);
            return(entity);
        }
        public void GivenReadObject_WhenReadCalledOnSameEntity_ThenSameObjectInstanceReturned()
        {
            // Given
            const string testName = "testName";
            var          random   = new Random(31);
            double       bottom   = random.NextDouble();
            var          entity   = new MacroStabilityInwardsSoilProfileOneDEntity
            {
                Name   = testName,
                Bottom = bottom,
                MacroStabilityInwardsSoilLayerOneDEntities =
                {
                    new MacroStabilityInwardsSoilLayerOneDEntity
                    {
                        Top = bottom + 0.5
                    }
                }
            };
            var collector = new ReadConversionCollector();

            MacroStabilityInwardsSoilProfile1D profile = entity.Read(collector);

            // When
            MacroStabilityInwardsSoilProfile1D secondProfile = entity.Read(collector);

            // Then
            Assert.AreSame(profile, secondProfile);
        }
示例#14
0
        private static bool ValidateTopOfProfileExceedsSurfaceLineTop(IMacroStabilityInwardsWaternetInput inputParameters,
                                                                      MacroStabilityInwardsSoilProfile1D soilProfile1D)
        {
            double layerTop       = soilProfile1D.Layers.Max(l => l.Top);
            double surfaceLineTop = inputParameters.SurfaceLine.LocalGeometry.Max(p => p.Y);

            return(layerTop + withinSurfaceLineLevelLimit >= surfaceLineTop);
        }
示例#15
0
        public void StochasticSoilProfile_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            MacroStabilityInwardsSoilProfile1D soilProfile = MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D();
            var newProfile = new MacroStabilityInwardsStochasticSoilProfile(0, soilProfile);
            var newValue   = new DataGridViewComboBoxItemWrapper <MacroStabilityInwardsStochasticSoilProfile>(newProfile);

            var calculation = new MacroStabilityInwardsCalculationScenario();

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.StochasticSoilProfile = newValue, calculation);
        }
示例#16
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="MacroStabilityInwardsStochasticSoilModel"/>.</returns>
        private static MacroStabilityInwardsStochasticSoilModel CreateSimpleModel(string modelName, params string[] profileNames)
        {
            var stochasticSoilProfiles = new List <MacroStabilityInwardsStochasticSoilProfile>();

            foreach (string profileName in profileNames)
            {
                MacroStabilityInwardsSoilProfile1D soilProfile = MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D(profileName);
                stochasticSoilProfiles.Add(new MacroStabilityInwardsStochasticSoilProfile(1.0 / profileNames.Length, soilProfile));
            }

            return(MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel(modelName, stochasticSoilProfiles));
        }
示例#17
0
        public void GivenInput_WhenStochasticSoilProfileSetAndSurfaceLineNull_ThenSoilProfileUnderSurfaceLineNull()
        {
            // Given
            var inputParameters = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties());

            // When
            MacroStabilityInwardsSoilProfile1D soilProfile = MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D();

            inputParameters.StochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0, soilProfile);

            // Then
            Assert.IsNull(inputParameters.SoilProfileUnderSurfaceLine);
        }
示例#18
0
        public void ToString_WithName_ReturnsName(string name)
        {
            // Setup
            var profile = new MacroStabilityInwardsSoilProfile1D(name, 0.0, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(0.0)
            });

            // Call
            var text = profile.ToString();

            // Assert
            Assert.AreEqual(name, text);
        }
        public void EditValue_WithCurrentItemNotInAvailableItems_ReturnsOriginalValue()
        {
            // 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>();

            var calculation      = new MacroStabilityInwardsCalculationScenario();
            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            MacroStabilityInwardsSoilProfile1D soilProfile = MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D();
            var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties())
            {
                StochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(1.0, soilProfile)
            };
            var inputContext = new MacroStabilityInwardsInputContext(input,
                                                                     calculation,
                                                                     Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                     new[]
            {
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel()
            },
                                                                     failureMechanism,
                                                                     assessmentSection);

            var properties = new MacroStabilityInwardsInputContextProperties(inputContext,
                                                                             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(someValue, result);

            mockRepository.VerifyAll();
        }
示例#20
0
        public void Create_StringPropertiesDoNotShareReference()
        {
            // Setup
            const string name = "some name";
            MacroStabilityInwardsSoilProfile1D soilProfile =
                MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D(name);
            var registry = new PersistenceRegistry();

            // Call
            MacroStabilityInwardsSoilProfileOneDEntity entity = soilProfile.Create(registry);

            // Assert
            TestHelper.AssertAreEqualButNotSame(name, entity.Name);
        }
示例#21
0
        public void Create_PersistenceRegistryNull_ThrowsArgumentNullException()
        {
            // Setup
            MacroStabilityInwardsSoilProfile1D soilProfile =
                MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D();

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

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

            Assert.AreEqual("registry", parameterName);
        }
示例#22
0
        public void GivenCreatedEntity_WhenCreateCalledOnSameObject_ThenSameEntityReturned()
        {
            // Given
            MacroStabilityInwardsSoilProfile1D soilProfile =
                MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D();
            var registry = new PersistenceRegistry();

            MacroStabilityInwardsSoilProfileOneDEntity firstEntity = soilProfile.Create(registry);

            // When
            MacroStabilityInwardsSoilProfileOneDEntity secondEntity = soilProfile.Create(registry);

            // Then
            Assert.AreSame(firstEntity, secondEntity);
        }
示例#23
0
        public void UpdateSoilProfileChartDataName_WithSoilProfile_NameSetToSoilProfileName()
        {
            // Setup
            var chartData   = new ChartDataCollection("test name");
            var soilProfile = new MacroStabilityInwardsSoilProfile1D("soil profile name", 2.0,
                                                                     new[]
            {
                new MacroStabilityInwardsSoilLayer1D(3.2)
            });

            // Call
            MacroStabilityInwardsChartDataFactory.UpdateSoilProfileChartDataName(chartData, soilProfile);

            // Assert
            Assert.AreEqual("soil profile name", chartData.Name);
        }
示例#24
0
        public void DynamicVisibleValidationMethod_AnyOtherProperty_ReturnsFalse()
        {
            // Setup
            var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", -5.0, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(-2)
            });
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.2, soilProfile);
            var properties            = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

            // Call
            bool otherVisible = properties.DynamicVisibleValidationMethod(string.Empty);

            // Assert
            Assert.IsFalse(otherVisible);
        }
示例#25
0
        public void GetLayerThickness_LayerInProfile_ReturnsThicknessOfLayer(int layerIndex, double expectedThickness)
        {
            // Setup
            var soilLayers = new[]
            {
                new MacroStabilityInwardsSoilLayer1D(0.0),
                new MacroStabilityInwardsSoilLayer1D(1.1)
            };
            var profile = new MacroStabilityInwardsSoilProfile1D(string.Empty, 0.0, soilLayers);

            // Call
            double thickness = profile.GetLayerThickness(soilLayers[layerIndex]);

            // Assert
            Assert.AreEqual(expectedThickness, thickness);
        }
        /// <summary>
        /// Creates an instance of <see cref="MacroStabilityInwardsStochasticSoilModel"/>.
        /// </summary>
        /// <param name="soilModelName">The name of the soil model.</param>
        /// <param name="geometry">The geometry of the soil model.</param>
        /// <returns>A valid configured <see cref="MacroStabilityInwardsStochasticSoilModel"/> with the
        /// specified <paramref name="soilModelName"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="soilModelName"/> or
        /// <paramref name="geometry"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <oaramref name="geometry"/> is
        /// <c>empty</c>.</exception>
        public static MacroStabilityInwardsStochasticSoilModel CreateValidStochasticSoilModel(string soilModelName,
                                                                                              IEnumerable <Point2D> geometry)
        {
            MacroStabilityInwardsSoilProfile1D soilProfileA =
                MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D("A");
            MacroStabilityInwardsSoilProfile1D soilProfileB =
                MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D("B");

            var model = new MacroStabilityInwardsStochasticSoilModel(soilModelName, geometry, new[]
            {
                new MacroStabilityInwardsStochasticSoilProfile(0.5, soilProfileA),
                new MacroStabilityInwardsStochasticSoilProfile(0.5, soilProfileB)
            });

            return(model);
        }
示例#27
0
        public void Create_WithNaNProperties_ReturnsEntityWithPropertiesSetToNull()
        {
            // Setup
            var random      = new Random(31);
            var soilProfile = new MacroStabilityInwardsSoilProfile1D("some name", double.NaN, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(random.NextDouble())
            });
            var registry = new PersistenceRegistry();

            // Call
            MacroStabilityInwardsSoilProfileOneDEntity entity = soilProfile.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.IsNull(entity.Bottom);
        }
示例#28
0
        public void GetStochasticSoilModelsForSurfaceLine_SoilModelGeometryNotIntersecting_ReturnEmpty()
        {
            // Setup
            var soilProfile1 = new MacroStabilityInwardsSoilProfile1D("Profile 1", -10.0, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(-5.0),
                new MacroStabilityInwardsSoilLayer1D(-2.0),
                new MacroStabilityInwardsSoilLayer1D(1.0)
            });
            var soilProfile2 = new MacroStabilityInwardsSoilProfile1D("Profile 2", -8.0, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(-4.0),
                new MacroStabilityInwardsSoilLayer1D(0.0),
                new MacroStabilityInwardsSoilLayer1D(4.0)
            });

            var soilModel = new MacroStabilityInwardsStochasticSoilModel("A", new[]
            {
                new Point2D(1.0, 0.0),
                new Point2D(5.0, 0.0)
            }, new[]
            {
                new MacroStabilityInwardsStochasticSoilProfile(0.3, soilProfile1),
                new MacroStabilityInwardsStochasticSoilProfile(0.7, soilProfile2)
            });

            MacroStabilityInwardsStochasticSoilModel[] availableSoilModels =
            {
                soilModel
            };

            var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0.0, 1.0, 0.0),
                new Point3D(2.5, 1.0, 1.0),
                new Point3D(5.0, 1.0, 0.0)
            });

            // Call
            IEnumerable <MacroStabilityInwardsStochasticSoilModel> result = MacroStabilityInwardsCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine(surfaceLine, availableSoilModels);

            // Assert
            CollectionAssert.IsEmpty(result);
        }
        public void Create_SurfaceLineNull_ThrowArgumentNullException()
        {
            // Setup
            var soilLayer   = new MacroStabilityInwardsSoilLayer1D(3.2);
            var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", 2.0, new[]
            {
                soilLayer
            });

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

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

            Assert.AreEqual("surfaceLine", exception.ParamName);
        }
示例#30
0
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var soilProfile1 = new MacroStabilityInwardsSoilProfile1D("soilProfile1", 0, new List <MacroStabilityInwardsSoilLayer1D>
            {
                new MacroStabilityInwardsSoilLayer1D(10)
            });
            var soilProfile2 = new MacroStabilityInwardsSoilProfile1D("soilProfile2", 0, new List <MacroStabilityInwardsSoilLayer1D>
            {
                new MacroStabilityInwardsSoilLayer1D(10)
            });
            var stochasticSoilProfile1 = new MacroStabilityInwardsStochasticSoilProfile(1.0, soilProfile1);
            var stochasticSoilProfile2 = new MacroStabilityInwardsStochasticSoilProfile(1.0, soilProfile2);

            MacroStabilityInwardsStochasticSoilModel stochasticSoilModel =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel(new[]
            {
                stochasticSoilProfile1,
                stochasticSoilProfile2
            });

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            var stochasticSoilModelCollectionContext = new MacroStabilityInwardsStochasticSoilModelCollectionContext(
                failureMechanism.StochasticSoilModels,
                failureMechanism,
                assessmentSection);

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

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

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                stochasticSoilModel
            }, objects);
        }