Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public void Create_ProfileWithMultipleLayers_ReturnsProfileWithOrderedMultipleLayers()
        {
            // Setup
            var    random         = new Random(22);
            double expectedTopA   = random.NextDouble();
            double expectedTopB   = random.NextDouble() + expectedTopA;
            double expectedTopC   = random.NextDouble() + expectedTopB;
            double expectedBottom = expectedTopA - random.NextDouble();
            var    layers         = new[]
            {
                new PipingSoilLayer(expectedTopA)
                {
                    IsAquifer = true
                },
                new PipingSoilLayer(expectedTopB),
                new PipingSoilLayer(expectedTopC)
            };
            var soilProfile = new PipingSoilProfile(string.Empty, expectedBottom, layers, SoilProfileType.SoilProfile1D);

            // Precondition
            CollectionAssert.AreNotEqual(layers, layers.OrderByDescending(l => l.Top), "Layer collection should not be in descending order by the Top property.");

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

            // Assert
            IEnumerable <PipingLayer> ordered = actual.Layers.OrderByDescending(l => l.TopLevel);

            CollectionAssert.AreEqual(ordered, actual.Layers);

            Assert.AreEqual(3, actual.Layers.Count);
            IEnumerable expectedAquifers = new[]
            {
                false,
                false,
                true
            };

            CollectionAssert.AreEqual(expectedAquifers, actual.Layers.Select(l => l.IsAquifer));
            CollectionAssert.AreEqual(new[]
            {
                expectedTopC,
                expectedTopB,
                expectedTopA
            }, actual.Layers.Select(l => l.TopLevel));
            Assert.AreEqual(expectedBottom, actual.BottomLevel);
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        public void Create_ProfileWithDecreasingTops_ReturnsProfileWithMultipleLayers()
        {
            // Setup
            var    random         = new Random(22);
            double expectedTopA   = random.NextDouble();
            double expectedTopB   = expectedTopA - random.NextDouble();
            double expectedTopC   = expectedTopB - random.NextDouble();
            double expectedBottom = expectedTopC - random.NextDouble();
            var    layers         = new[]
            {
                new PipingSoilLayer(expectedTopA)
                {
                    IsAquifer = true
                },
                new PipingSoilLayer(expectedTopB),
                new PipingSoilLayer(expectedTopC)
            };

            var soilProfile = new PipingSoilProfile(string.Empty, expectedBottom, layers, SoilProfileType.SoilProfile1D);

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

            // Assert
            Assert.AreEqual(3, actual.Layers.Count);
            IEnumerable expectedAquifers = new[]
            {
                true,
                false,
                false
            };

            CollectionAssert.AreEqual(expectedAquifers, actual.Layers.Select(l => l.IsAquifer));
            CollectionAssert.AreEqual(new[]
            {
                expectedTopA,
                expectedTopB,
                expectedTopC
            }, actual.Layers.Select(l => l.TopLevel));
            Assert.AreEqual(expectedBottom, actual.BottomLevel);
        }
Ejemplo n.º 5
0
 public void SetSoilProfile(PipingProfile soilProfile)
 {
     SoilProfile = soilProfile;
 }
Ejemplo n.º 6
0
 public void SetSoilProfile(PipingProfile soilProfile)
 {
     wrappedCalculator.SoilProfile = soilProfile;
 }