public void Update_ModelWithRemovedProfileSameNameOtherType_ProfileRemoved() { // Setup const string profileName = "A"; var soilProfile = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers1D()); var expectedRemovedProfile = new MacroStabilityInwardsStochasticSoilProfile(0.2, soilProfile); var newProfile = new MacroStabilityInwardsStochasticSoilProfile( 0.2, new MacroStabilityInwardsSoilProfile2D(profileName, CreateLayers2D(), Enumerable.Empty <MacroStabilityInwardsPreconsolidationStress>())); MacroStabilityInwardsStochasticSoilModel model = CreateValidModel(new[] { expectedRemovedProfile }); MacroStabilityInwardsStochasticSoilModel otherModel = CreateValidModel(new[] { newProfile }); // Call MacroStabilityInwardsStochasticSoilModelProfileDifference difference = model.Update(otherModel); // Assert CollectionAssert.AreEqual(new[] { newProfile }, difference.AddedProfiles); CollectionAssert.IsEmpty(difference.UpdatedProfiles); CollectionAssert.AreEqual(new[] { expectedRemovedProfile }, difference.RemovedProfiles); }
public void Update_ModelWithUpdatedStochasticSoilProfile_ProfileUpdated() { // Setup const string profileName = "A"; var soilProfile = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers1D()); var expectedUpdatedProfile = new MacroStabilityInwardsStochasticSoilProfile(0.2, soilProfile); MacroStabilityInwardsStochasticSoilModel model = CreateValidModel(new[] { expectedUpdatedProfile }); MacroStabilityInwardsStochasticSoilModel otherModel = CreateValidModel(new[] { new MacroStabilityInwardsStochasticSoilProfile(0.5, soilProfile) }); // Call MacroStabilityInwardsStochasticSoilModelProfileDifference difference = model.Update(otherModel); // Assert CollectionAssert.IsEmpty(difference.AddedProfiles); CollectionAssert.AreEqual(new[] { expectedUpdatedProfile }, difference.UpdatedProfiles); CollectionAssert.IsEmpty(difference.RemovedProfiles); }
public void Update_ModelWithAddedProfile_ProfileAdded() { // Setup MacroStabilityInwardsStochasticSoilModel model = CreateValidModel(new[] { CreateStochasticSoilProfile() }); var expectedAddedProfile = new MacroStabilityInwardsStochasticSoilProfile(0.2, new TestSoilProfile("Added Profile")); MacroStabilityInwardsStochasticSoilModel otherModel = CreateValidModel(new[] { CreateStochasticSoilProfile(), expectedAddedProfile }); // Call MacroStabilityInwardsStochasticSoilModelProfileDifference difference = model.Update(otherModel); // Assert AssertStochasticSoilModelAreEqual(otherModel, model); CollectionAssert.AreEqual(new[] { expectedAddedProfile }, difference.AddedProfiles); CollectionAssert.IsEmpty(difference.UpdatedProfiles); CollectionAssert.IsEmpty(difference.RemovedProfiles); }
public void Update_ModelWithUpdatedProperties_PropertiesUpdated() { // Setup var model = new MacroStabilityInwardsStochasticSoilModel("name", new[] { new Point2D(1, 2), new Point2D(4, 5) }, new[] { CreateStochasticSoilProfile() }); const string expectedName = "otherName"; var otherModel = new MacroStabilityInwardsStochasticSoilModel(expectedName, new[] { new Point2D(4, 2) }, new[] { CreateStochasticSoilProfile() }); // Call MacroStabilityInwardsStochasticSoilModelProfileDifference difference = model.Update(otherModel); // Assert AssertStochasticSoilModelAreEqual(otherModel, model); CollectionAssert.IsEmpty(difference.AddedProfiles); CollectionAssert.IsEmpty(difference.UpdatedProfiles); CollectionAssert.IsEmpty(difference.RemovedProfiles); }
public void Update_WithOtherModel_PropertiesUpdated() { // Setup const string equalProfileName = "nameA"; var stochasticProfileA = new MacroStabilityInwardsStochasticSoilProfile(0.5, CreateMacroStabilityInwardsSoilProfile(equalProfileName)); var stochasticProfileB = new MacroStabilityInwardsStochasticSoilProfile(0.5, CreateMacroStabilityInwardsSoilProfile("nameB")); MacroStabilityInwardsStochasticSoilModel model = CreateValidModel(new[] { stochasticProfileA, stochasticProfileB }); const string otherName = "other name"; var otherGeometry = new[] { new Point2D(2, 0), new Point2D(3, 0) }; var otherStochasticProfileA = new MacroStabilityInwardsStochasticSoilProfile(0.7, new TestSoilProfile(equalProfileName)); var otherStochasticProfileB = new MacroStabilityInwardsStochasticSoilProfile(0.3, CreateMacroStabilityInwardsSoilProfile("other profile name")); var otherModel = new MacroStabilityInwardsStochasticSoilModel(otherName, otherGeometry, new[] { otherStochasticProfileA, otherStochasticProfileB }); // Call MacroStabilityInwardsStochasticSoilModelProfileDifference difference = model.Update(otherModel); // Assert AssertStochasticSoilModelAreEqual(otherModel, model); Assert.AreSame(otherGeometry, model.Geometry); MacroStabilityInwardsStochasticSoilProfile[] 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); }
public void Update_WithNullModel_ThrowsArgumentNullException() { // Setup MacroStabilityInwardsStochasticSoilModel model = CreateValidModel(new[] { CreateStochasticSoilProfile() }); // Call TestDelegate test = () => model.Update(null); // Assert string paramName = Assert.Throws <ArgumentNullException>(test).ParamName; Assert.AreEqual("fromModel", paramName); }
public void Update_ModelsWithAddedProfilesWithSameNames_ThrowsInvalidOperationException() { // Setup const string profileName = "Name of Profile"; MacroStabilityInwardsSoilProfile1D soilProfileOne = MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D(profileName); var addedStochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.2, soilProfileOne); MacroStabilityInwardsStochasticSoilModel otherModel = CreateValidModel(new[] { addedStochasticSoilProfile }); MacroStabilityInwardsSoilProfile1D soilProfile = MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D(profileName); var existingStochasticSoilProfileOne = new MacroStabilityInwardsStochasticSoilProfile(0.2, soilProfile); var existingStochasticSoilProfileTwo = new MacroStabilityInwardsStochasticSoilProfile(0.3, soilProfile); MacroStabilityInwardsStochasticSoilModel model = CreateValidModel(new[] { existingStochasticSoilProfileOne, existingStochasticSoilProfileTwo }); // Call TestDelegate call = () => model.Update(otherModel); // Assert Assert.Throws <InvalidOperationException>(call); Assert.AreEqual(1, otherModel.StochasticSoilProfiles.Count()); Assert.AreEqual(addedStochasticSoilProfile, otherModel.StochasticSoilProfiles.First()); Assert.AreEqual(2, model.StochasticSoilProfiles.Count()); CollectionAssert.AreEqual(new[] { existingStochasticSoilProfileOne, existingStochasticSoilProfileTwo }, model.StochasticSoilProfiles); }