public void Transform_SoilProfile1DWithSingleLayer_ReturnsProfileWithBottomAndALayer() { // Setup const string profileName = "SomeProfile"; var random = new Random(22); double bottom = random.NextDouble(); double top = random.NextDouble(); const long pipingSoilProfileId = 1234L; var profile = new SoilProfile1D(pipingSoilProfileId, profileName, bottom, new[] { SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(top) } ); // Call PipingSoilProfile transformed = PipingSoilProfileTransformer.Transform(profile); // Assert Assert.AreEqual(profileName, transformed.Name); Assert.AreEqual(SoilProfileType.SoilProfile1D, transformed.SoilProfileSourceType); PipingSoilLayer[] layers = transformed.Layers.ToArray(); Assert.AreEqual(1, layers.Length); Assert.AreEqual(top, layers[0].Top); Assert.AreEqual(bottom, transformed.Bottom); }
public void Transform_SoilProfile1DWithMultipleLayers_ReturnsProfileWithBottomAndALayer() { // Setup const string profileName = "SomeProfile"; var random = new Random(22); double bottom = random.NextDouble(); double top = bottom + random.NextDouble(); double top2 = bottom + random.NextDouble(); const long pipingSoilProfileId = 1234L; var profile = new SoilProfile1D(pipingSoilProfileId, profileName, bottom, new[] { SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(top), SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(top2) } ); // Call PipingSoilProfile transformed = PipingSoilProfileTransformer.Transform(profile); // Assert Assert.AreEqual(profileName, transformed.Name); Assert.AreEqual(2, transformed.Layers.Count()); Assert.AreEqual(bottom, transformed.Bottom); }
public void SoilLayer1DTransform_ValidColors_ReturnsMacroStabilityInwardsSoilLayer1D(double?color, Color transformedColor) { // Setup SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.Color = color; // Call MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer); // Assert Assert.AreEqual(transformedColor, soilLayer1D.Data.Color); }
public void SoilLayer1DTransform_ValidIsAquifer_ReturnsMacroStabilityInwardsSoilLayer1D(double isAquifer, bool transformedIsAquifer) { // Setup SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.IsAquifer = isAquifer; // Call MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer); // Assert Assert.AreEqual(transformedIsAquifer, soilLayer1D.Data.IsAquifer); }
public void SoilLayer1DTransform_ValidUsePopValue_ReturnMacroStabilityInwardSoilLayer1D(double?usePop, bool transformedUsePopValue) { // Setup SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.UsePop = usePop; // Call MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer); // Assert Assert.AreEqual(transformedUsePopValue, soilLayer1D.Data.UsePop); }
public void SoilLayer1DTransform_ValidShearStrengthModelValue_ReturnMacroStabilityInwardSoilLayer1D(double?sheartStrengthModel, MacroStabilityInwardsShearStrengthModel transformedShearStrengthModel) { // Setup SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.ShearStrengthModel = sheartStrengthModel; // Call MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer); // Assert Assert.AreEqual(transformedShearStrengthModel, soilLayer1D.Data.ShearStrengthModel); }
public void SoilLayer1DTransform_InvalidShearStrengthModelValue_ThrowsImportedDataTransformException() { // Setup SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.ShearStrengthModel = 2; // Call TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer); // Assert var exception = Assert.Throws <ImportedDataTransformException>(test); string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName, "Ongeldige waarde voor parameter 'Schuifsterkte model'."); Assert.AreEqual(expectedMessage, exception.Message); }
public void SoilLayer1DTransform_ShearStrengthModelValueNone_ThrowsImportedDataTransformException() { // Setup SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.ShearStrengthModel = 1; // Call TestDelegate call = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer); // Assert var exception = Assert.Throws <ImportedDataTransformException>(call); string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName, "Er is geen schuifsterkte model opgegeven."); Assert.AreEqual(expectedMessage, exception.Message); }
public void Transform_ValidSoilProfile1D_ReturnMacroStabilityInwardsSoilProfile1D() { // Setup var profile = new SoilProfile1D(1, "test", 3, new[] { SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer() }); // Call var transformedProfile = (MacroStabilityInwardsSoilProfile1D)MacroStabilityInwardsSoilProfileTransformer.Transform(profile); // Assert Assert.AreEqual(profile.Name, transformedProfile.Name); Assert.AreEqual(profile.Bottom, transformedProfile.Bottom); Assert.AreEqual(profile.Layers.Count(), transformedProfile.Layers.Count()); CollectionAssert.AllItemsAreInstancesOfType(transformedProfile.Layers, typeof(MacroStabilityInwardsSoilLayer1D)); }
public void SoilLayer1DTransform_InvalidIsAquifer_ThrowsImportedDataException(double?isAquifer) { // Setup SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.IsAquifer = isAquifer; // Call TestDelegate call = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer); // Assert var exception = Assert.Throws <ImportedDataTransformException>(call); string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName, "Ongeldige waarde voor parameter 'Is aquifer'."); Assert.AreEqual(expectedMessage, exception.Message); Assert.IsInstanceOf <NotSupportedException>(exception.InnerException); }
private static IEnumerable <TestCaseData> GetSupportedStochasticSoilProfilesWithInvalidProbabilities() { double[] invalidProbabilities = { double.NaN, double.NegativeInfinity, double.PositiveInfinity, 1.1, -0.1, 5, -5 }; const long id = 1; const string name = "test"; foreach (double invalidProbability in invalidProbabilities) { yield return(new TestCaseData(new StochasticSoilProfile(invalidProbability, new SoilProfile2D(id, name, new[] { SoilLayer2DTestFactory.CreateSoilLayer2D() }, Enumerable.Empty <PreconsolidationStress>()) { IntersectionX = 1.0 })) .SetName($"2D Soil Profile - {invalidProbability}")); yield return(new TestCaseData(new StochasticSoilProfile(invalidProbability, new SoilProfile1D(id, name, 1, new[] { SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer() }))) .SetName($"1D Soil Profile - {invalidProbability}")); } }
public void Transform_ValidStochasticSoilModelWithSoilProfile1D_ReturnsExpectedMacroStabilityInwardsStochasticSoilModel() { // Setup var random = new Random(21); double probability = random.NextDouble(); const double top = 4; var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer(); StochasticSoilModel soilModel = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateMacroStabilityInwardsStochasticSoilModelWithGeometry("some name", new[] { new StochasticSoilProfile(probability, new SoilProfile1D(2, "test", 3, new[] { SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(top) })) }); // Call MacroStabilityInwardsStochasticSoilModel transformedModel = transformer.Transform(soilModel); // Assert Assert.AreEqual(soilModel.Name, transformedModel.Name); CollectionAssert.AreEqual(soilModel.Geometry, transformedModel.Geometry); Assert.AreEqual(1, transformedModel.StochasticSoilProfiles.Count()); var expectedStochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(probability, new MacroStabilityInwardsSoilProfile1D("test", 3, new[] { new MacroStabilityInwardsSoilLayer1D(top) { Data = { UsePop = true, ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.CPhi, IsAquifer = false } } })); AssertStochasticSoilProfile(expectedStochasticSoilProfile, transformedModel.StochasticSoilProfiles.First()); }
public void Transform_ValidStochasticSoilModelWithSimilarProfileInTwoStochasticSoilProfiles_ReturnsExpectedPipingStochasticSoilModel() { // Setup var random = new Random(21); const string soilProfileName = "SoilProfile"; const double intersectionX = 1.0; var soilProfile2D = new SoilProfile2D(0, soilProfileName, new[] { SoilLayer2DTestFactory.CreateSoilLayer2D() }, Enumerable.Empty <PreconsolidationStress>()) { IntersectionX = intersectionX }; var stochasticSoilProfile2D = new StochasticSoilProfile(random.NextDouble(), soilProfile2D); var soilProfile1D = new SoilProfile1D(0, soilProfileName, 0, new[] { SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer() }); var stochasticSoilProfile1D = new StochasticSoilProfile(random.NextDouble(), soilProfile1D); var transformer = new PipingStochasticSoilModelTransformer(); StochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModelWithGeometry(new[] { stochasticSoilProfile2D, stochasticSoilProfile1D }); // Call PipingStochasticSoilModel transformed = transformer.Transform(soilModel); // Assert PipingStochasticSoilProfile[] transformedStochasticSoilProfiles = transformed.StochasticSoilProfiles.ToArray(); Assert.AreEqual(2, transformedStochasticSoilProfiles.Length); Assert.AreEqual(stochasticSoilProfile2D.Probability, transformedStochasticSoilProfiles[0].Probability, 1e-6); Assert.AreEqual(stochasticSoilProfile1D.Probability, transformedStochasticSoilProfiles[1].Probability, 1e-6); }
private static IEnumerable <TestCaseData> GetValidConfiguredAndSupportedSoilProfiles() { var random = new Random(21); const long id = 1; const string name = "test"; yield return(new TestCaseData(new SoilProfile2D(id, name, new[] { SoilLayer2DTestFactory.CreateSoilLayer2D() }, Enumerable.Empty <PreconsolidationStress>()) { IntersectionX = random.NextDouble() + 1 }) .SetName("2D Profile")); yield return(new TestCaseData(new SoilProfile1D(id, name, random.NextDouble(), new[] { SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer() })) .SetName("1D Profile")); }
private static IEnumerable <TestCaseData> InvalidStochasticDistributionValuesSoilLayer1D() { return(InvalidStochasticDistributionValues(() => SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer())); }