Beispiel #1
0
        public void Update_ModelWithUpdatedStochasticSoilProfile_ProfileUpdated()
        {
            // Setup
            const string profileName            = "A";
            var          soilProfile            = new PipingSoilProfile(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D);
            var          expectedUpdatedProfile = new PipingStochasticSoilProfile(0.2, soilProfile);
            PipingStochasticSoilModel model     = CreateValidModel(new[]
            {
                expectedUpdatedProfile
            });

            PipingStochasticSoilModel otherModel = CreateValidModel(new[]
            {
                new PipingStochasticSoilProfile(0.5, soilProfile)
            });

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

            // Assert
            CollectionAssert.IsEmpty(difference.AddedProfiles);
            CollectionAssert.AreEqual(new[]
            {
                expectedUpdatedProfile
            }, difference.UpdatedProfiles);
            CollectionAssert.IsEmpty(difference.RemovedProfiles);
        }
Beispiel #2
0
        public void Update_ModelWithUpdatedProperties_PropertiesUpdated()
        {
            // Setup
            var model = new PipingStochasticSoilModel("name", new[]
            {
                new Point2D(1, 2),
                new Point2D(4, 5)
            }, new[]
            {
                CreateStochasticSoilProfile()
            });

            const string expectedName     = "otherName";
            var          expectedGeometry = new[]
            {
                new Point2D(4, 2)
            };

            var otherModel = new PipingStochasticSoilModel(expectedName, expectedGeometry, new[]
            {
                CreateStochasticSoilProfile()
            });

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

            // Assert
            Assert.AreEqual(expectedName, model.Name);
            CollectionAssert.AreEqual(expectedGeometry, model.Geometry);

            CollectionAssert.IsEmpty(difference.AddedProfiles);
            CollectionAssert.IsEmpty(difference.UpdatedProfiles);
            CollectionAssert.IsEmpty(difference.RemovedProfiles);
        }
Beispiel #3
0
        public void Update_ModelWithAddedProfile_ProfileAdded()
        {
            // Setup
            PipingStochasticSoilModel model = CreateValidModel(new[]
            {
                CreateStochasticSoilProfile()
            });

            var expectedAddedProfile             = new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile());
            PipingStochasticSoilModel otherModel = CreateValidModel(new[]
            {
                expectedAddedProfile,
                CreateStochasticSoilProfile()
            });

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

            // Assert
            Assert.AreEqual(2, otherModel.StochasticSoilProfiles.Count());
            Assert.AreEqual(expectedAddedProfile, otherModel.StochasticSoilProfiles.First());

            CollectionAssert.AreEqual(new[]
            {
                expectedAddedProfile
            }, difference.AddedProfiles);
            CollectionAssert.IsEmpty(difference.UpdatedProfiles);
            CollectionAssert.IsEmpty(difference.RemovedProfiles);
        }
Beispiel #4
0
        public void Update_WithOtherModel_PropertiesUpdated()
        {
            // Setup
            const string equalProfileName   = "nameA";
            var          stochasticProfileA = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile(equalProfileName));
            var          stochasticProfileB = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile("nameB"));
            PipingStochasticSoilModel model = CreateValidModel(new[]
            {
                stochasticProfileA,
                stochasticProfileB
            });

            const string otherName     = "other name";
            var          otherGeometry = new[]
            {
                new Point2D(2, 0),
                new Point2D(3, 0)
            };
            var otherStochasticProfileA = new PipingStochasticSoilProfile(
                0.7, new PipingSoilProfile(equalProfileName, -1, new[]
            {
                new PipingSoilLayer(0)
            }, SoilProfileType.SoilProfile1D));
            var otherStochasticProfileB = new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile("other profile name"));
            var otherModel = new PipingStochasticSoilModel(otherName, otherGeometry, new[]
            {
                otherStochasticProfileA,
                otherStochasticProfileB
            });

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

            // Assert
            Assert.AreEqual(otherName, model.Name);
            Assert.AreSame(otherGeometry, model.Geometry);

            PipingStochasticSoilProfile[] stochasticSoilProfiles = model.StochasticSoilProfiles.ToArray();
            Assert.AreEqual(2, stochasticSoilProfiles.Length);
            Assert.AreSame(stochasticProfileA, stochasticSoilProfiles[0]);
            Assert.AreSame(otherStochasticProfileA.SoilProfile, stochasticSoilProfiles[0].SoilProfile);
            Assert.AreNotSame(stochasticProfileB, stochasticSoilProfiles[1]);
            Assert.AreSame(otherStochasticProfileB.SoilProfile, stochasticSoilProfiles[1].SoilProfile);

            CollectionAssert.AreEqual(new[]
            {
                stochasticProfileA
            }, difference.UpdatedProfiles);
            CollectionAssert.AreEqual(new[]
            {
                stochasticProfileB
            }, difference.RemovedProfiles);
            CollectionAssert.AreEqual(new[]
            {
                otherStochasticProfileB
            }, difference.AddedProfiles);
        }
Beispiel #5
0
        public void Update_WithNullModel_ThrowsArgumentNullException()
        {
            // Setup
            var model = new PipingStochasticSoilModel("name", new[]
            {
                new Point2D(1, 1)
            },
                                                      new[]
            {
                CreateStochasticSoilProfile()
            });

            // Call
            void Call() => model.Update(null);

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

            Assert.AreEqual("fromModel", exception.ParamName);
        }