public void CreateSoilLayerChartData_WithLayer_ReturnsEmptyChartDataCollectionWithExpectedStyling() { // Setup const string name = "Soil layer test name"; Color fillColor = Color.Firebrick; MacroStabilityInwardsSoilLayer2D layer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(); layer.Data.MaterialName = name; layer.Data.Color = fillColor; // Call ChartMultipleAreaData data = MacroStabilityInwardsChartDataFactory.CreateSoilLayerChartData(layer); // Assert CollectionAssert.IsEmpty(data.Areas); Assert.AreEqual(name, data.Name); AssertEqualStyle(data.Style, fillColor, Color.Black, 1, false); }
public void AddGeometryLayer_StageTypeAlreadyRegistered_AddsGeometryLayerId() { // Setup MacroStabilityInwardsSoilLayer2D geometryLayer1 = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(); MacroStabilityInwardsSoilLayer2D geometryLayer2 = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(); geometryLayer2.Data.MaterialName = "Test material"; geometryLayer2.Data.IsAquifer = true; var registry = new MacroStabilityInwardsExportRegistry(); var stageType = new Random(21).NextEnumValue <MacroStabilityInwardsExportStageType>(); const string id1 = "1"; const string id2 = "2"; registry.AddGeometryLayer(stageType, geometryLayer1, id1); // Precondition Assert.AreEqual(1, registry.GeometryLayers.Count); // Call registry.AddGeometryLayer(stageType, geometryLayer2, id2); // Assert Assert.AreEqual(1, registry.GeometryLayers.Count); KeyValuePair <MacroStabilityInwardsExportStageType, Dictionary <MacroStabilityInwardsSoilLayer2D, string> > registeredStageTypeGeometry = registry.GeometryLayers.Single(); Assert.AreEqual(stageType, registeredStageTypeGeometry.Key); Assert.AreEqual(2, registeredStageTypeGeometry.Value.Count); Dictionary <MacroStabilityInwardsSoilLayer2D, string> registeredGeometries = registeredStageTypeGeometry.Value; KeyValuePair <MacroStabilityInwardsSoilLayer2D, string> registeredGeometry1 = registeredGeometries.First(); Assert.AreSame(geometryLayer1, registeredGeometry1.Key); Assert.AreEqual(id1, registeredGeometry1.Value); KeyValuePair <MacroStabilityInwardsSoilLayer2D, string> registeredGeometry2 = registeredGeometries.Last(); Assert.AreSame(geometryLayer2, registeredGeometry2.Key); Assert.AreEqual(id2, registeredGeometry2.Value); }
public void Create_WithValidData_ReturnsNull() { // Setup var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D() }) }, Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>()); var registry = new MacroStabilityInwardsExportRegistry(); // Call IEnumerable <PersistableGeometry> geometries = PersistableGeometryFactory.Create(soilProfile, new IdFactory(), registry); // Assert IEnumerable <MacroStabilityInwardsSoilLayer2D> layersRecursively = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfile.Layers); PersistableDataModelTestHelper.AssertPersistableGeometry(layersRecursively, geometries); AssertRegistry(registry, geometries, layersRecursively); }
public void Create_WithValidData_ReturnsPersistableSoilLayerCollectionCollection() { // Setup var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine( new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D() }) }, Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>()); var idFactory = new IdFactory(); var registry = new MacroStabilityInwardsExportRegistry(); PersistableSoilCollection soils = PersistableSoilCollectionFactory.Create(soilProfile, idFactory, registry); IEnumerable <PersistableGeometry> geometries = PersistableGeometryFactory.Create(soilProfile, idFactory, registry); // Call IEnumerable <PersistableSoilLayerCollection> soilLayerCollections = PersistableSoilLayerCollectionFactory.Create(soilProfile, idFactory, registry); // Assert PersistableDataModelTestHelper.AssertPersistableSoilLayers(soilProfile.Layers, soilLayerCollections, soils.Soils, geometries); var stages = new[] { MacroStabilityInwardsExportStageType.Daily, MacroStabilityInwardsExportStageType.Extreme }; Assert.AreEqual(2, registry.SoilLayers.Count); for (var i = 0; i < stages.Length; i++) { Assert.AreEqual(registry.SoilLayers[stages[i]], soilLayerCollections.ElementAt(i).Id); } }
public void Create_InvalidShearStrengthType_ThrowsInvalidEnumArgumentException() { // Setup var registry = new MacroStabilityInwardsExportRegistry(); var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine( new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D() }, Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>()); const MacroStabilityInwardsShearStrengthModel shearStrengthModel = (MacroStabilityInwardsShearStrengthModel)99; soilProfile.Layers.First().Data.ShearStrengthModel = shearStrengthModel; // Call void Call() => PersistableSoilCollectionFactory.Create(soilProfile, new IdFactory(), registry); // Assert string message = $"The value of argument 'shearStrengthModel' ({shearStrengthModel}) is invalid for Enum type '{nameof(MacroStabilityInwardsShearStrengthModel)}'."; var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, message); Assert.AreEqual("shearStrengthModel", exception.ParamName); }
public void AddGeometryLayer_NewStageType_AddsStageTypeAndGeometryLayerId() { // Setup MacroStabilityInwardsSoilLayer2D geometryLayer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(); var registry = new MacroStabilityInwardsExportRegistry(); var stageType = new Random(21).NextEnumValue <MacroStabilityInwardsExportStageType>(); const string id = "1"; // Call registry.AddGeometryLayer(stageType, geometryLayer, id); // Assert Assert.AreEqual(1, registry.GeometryLayers.Count); KeyValuePair <MacroStabilityInwardsExportStageType, Dictionary <MacroStabilityInwardsSoilLayer2D, string> > registeredStorageTypeGeometry = registry.GeometryLayers.Single(); Assert.AreEqual(stageType, registeredStorageTypeGeometry.Key); Assert.AreEqual(1, registeredStorageTypeGeometry.Value.Count); KeyValuePair <MacroStabilityInwardsSoilLayer2D, string> registeredGeometry = registeredStorageTypeGeometry.Value.Single(); Assert.AreSame(geometryLayer, registeredGeometry.Key); Assert.AreEqual(id, registeredGeometry.Value); }
public void Create_WithValidProperties_ReturnsEntityWithPropertiesSet() { // Setup var soilProfile = new MacroStabilityInwardsSoilProfile2D("some name", new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(), MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D() }, new[] { MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress() }); var registry = new PersistenceRegistry(); // Call MacroStabilityInwardsSoilProfileTwoDEntity entity = soilProfile.Create(registry); // Assert Assert.IsNotNull(entity); Assert.AreEqual(soilProfile.Layers.Count(), entity.MacroStabilityInwardsSoilLayerTwoDEntities.Count); Assert.AreEqual(soilProfile.PreconsolidationStresses.Count(), entity.MacroStabilityInwardsPreconsolidationStressEntities.Count); AssertPreconsolidationStress(soilProfile.PreconsolidationStresses.First(), entity.MacroStabilityInwardsPreconsolidationStressEntities.First()); }
public void Create_WithNestedLayers_ReturnsEntityWithNestedLayersSet() { // Setup MacroStabilityInwardsSoilLayer2D parentLayer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(new[] { CreateMacroStabilityInwardsSoilLayer2D(), CreateMacroStabilityInwardsSoilLayer2D(), CreateMacroStabilityInwardsSoilLayer2D() }); // Call MacroStabilityInwardsSoilLayerTwoDEntity entity = parentLayer.Create(0); // Assert Assert.IsNotNull(entity); Assert.AreEqual(parentLayer.NestedLayers.Count(), entity.MacroStabilityInwardsSoilLayerTwoDEntity1.Count); for (var i = 0; i < parentLayer.NestedLayers.Count(); i++) { AssertMacroStabilityInwardsSoilLayerTwoDEntity(parentLayer.NestedLayers.ElementAt(i), entity.MacroStabilityInwardsSoilLayerTwoDEntity1.ElementAt(i), i); } }