Exemple #1
0
        public void Create_ProfileWithOneLayer_ReturnsProfileWithSingleLayer()
        {
            // Setup
            var    random         = new Random(22);
            double expectedTop    = random.NextDouble();
            double expectedBottom = expectedTop - random.NextDouble();

            var layers = new[]
            {
                new PipingSoilLayer(expectedTop)
                {
                    IsAquifer = true
                }
            };
            var soilProfile = new PipingSoilProfile(string.Empty, expectedBottom, layers, SoilProfileType.SoilProfile1D);

            // Call
            PipingProfile actual = PipingProfileCreator.Create(soilProfile);

            // Assert
            Assert.IsNotNull(actual.Layers);
            Assert.IsNotNull(actual.BottomAquiferLayer);
            Assert.IsNotNull(actual.TopAquiferLayer);
            Assert.AreEqual(1, actual.Layers.Count);
            Assert.AreEqual(expectedTop, actual.Layers[0].TopLevel);
            Assert.AreEqual(expectedTop, actual.TopLevel);
            Assert.AreEqual(expectedBottom, actual.BottomLevel);

            PipingLayer pipingLayer = actual.Layers.First();

            Assert.IsTrue(pipingLayer.IsAquifer);
        }
        /// <summary>
        /// Creates a <see cref="PipingProfile"/> based on information contained in the provided <paramref name="soilProfile"/>,
        /// which can then be used in the <see cref="PipingCalculator"/>.
        /// </summary>
        /// <param name="soilProfile">The <see cref="PipingSoilProfile"/> from which to take the information.</param>
        /// <returns>A new <see cref="PipingProfile"/> with information taken from the <paramref name="soilProfile"/>.</returns>
        public static PipingProfile Create(PipingSoilProfile soilProfile)
        {
            var profile = new PipingProfile
            {
                BottomLevel = soilProfile.Bottom
            };

            foreach (PipingSoilLayer layer in soilProfile.Layers)
            {
                var pipingLayer = new PipingLayer
                {
                    TopLevel  = layer.Top,
                    IsAquifer = layer.IsAquifer
                };

                profile.Layers.Add(pipingLayer);
            }

            return(profile);
        }