public void ForeshoreProfile_Always_InputChangedAndObservablesNotified() { var profile = new TestForeshoreProfile(); SetPropertyAndVerifyNotificationsAndOutput( properties => properties.ForeshoreProfile = profile); }
public void TryReadForeshoreProfile_WithForeshoreProfileToFindForeshoreProfilesContainsProfile_ReturnsTrue() { // Setup const string profileName = "someName"; const string calculationName = "name"; string filePath = Path.Combine(readerPath, "validConfiguration.xml"); var calculationGroup = new CalculationGroup(); var importer = new CalculationConfigurationImporter(filePath, calculationGroup); ForeshoreProfile expectedProfile = new TestForeshoreProfile(profileName); // Call bool valid = importer.PublicTryReadForeshoreProfile(profileName, calculationName, new[] { new TestForeshoreProfile("otherNameA"), expectedProfile, new TestForeshoreProfile("otherNameB") }, out ForeshoreProfile profile); // Assert Assert.IsTrue(valid); Assert.AreSame(expectedProfile, profile); }
public void Import_UseForeshoreTrueButProfileWithoutForeshoreGeometry_LogMessageAndContinueImport() { // Setup string filePath = Path.Combine(path, "validConfigurationCalculationUseForeshoreTrueForeshoreProfileWithoutGeometry.xml"); var calculationGroup = new CalculationGroup(); var foreshoreProfile = new TestForeshoreProfile("Voorlandprofiel"); var importer = new TestWaveConditionsCalculationConfigurationImporter( filePath, calculationGroup, Enumerable.Empty <HydraulicBoundaryLocation>(), new[] { foreshoreProfile }, new FailureMechanismContribution(0.1, 0.1), Enumerable.Empty <HydraulicBoundaryLocationCalculationsForTargetProbability>()); // Call var successful = false; Action call = () => successful = importer.Import(); // Assert const string expectedMessage = "Het opgegeven voorlandprofiel 'Voorlandprofiel' heeft geen voorlandgeometrie en kan daarom niet gebruikt worden. Berekening 'Berekening 1' is overgeslagen."; TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 2); Assert.IsTrue(successful); CollectionAssert.IsEmpty(calculationGroup.Children); }
public void Create_WithForeshoreProfiles_ForeshoreProfileEntitiesCreated() { // Setup var profile = new TestForeshoreProfile(); var failureMechanism = new ClosingStructuresFailureMechanism(); const string filePath = "some/file/path/foreshoreProfiles"; failureMechanism.ForeshoreProfiles.AddRange(new[] { profile }, filePath); var persistenceRegistry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(persistenceRegistry); // Assert Assert.AreEqual(1, entity.ForeshoreProfileEntities.Count); Assert.IsTrue(persistenceRegistry.Contains(profile)); ClosingStructuresFailureMechanismMetaEntity metaEntity = entity.ClosingStructuresFailureMechanismMetaEntities.Single(); string metaEntityForeshoreProfileCollectionSourcePath = metaEntity.ForeshoreProfileCollectionSourcePath; TestHelper.AssertAreEqualButNotSame(filePath, metaEntityForeshoreProfileCollectionSourcePath); }
public void EditValue_WithCurrentItemInAvailableItems_ReturnsCurrentItem() { // Setup var foreshoreProfile = new TestForeshoreProfile(); var properties = new ObjectPropertiesWithForeshoreProfile(foreshoreProfile, new[] { foreshoreProfile }); var propertyBag = new DynamicPropertyBag(properties); var editor = new ForeshoreProfileEditor(); var someValue = new object(); var serviceProvider = mockRepository.Stub <IServiceProvider>(); var service = mockRepository.Stub <IWindowsFormsEditorService>(); var descriptorContext = mockRepository.Stub <ITypeDescriptorContext>(); serviceProvider.Stub(p => p.GetService(null)).IgnoreArguments().Return(service); descriptorContext.Stub(c => c.Instance).Return(propertyBag); mockRepository.ReplayAll(); // Call object result = editor.EditValue(descriptorContext, serviceProvider, someValue); // Assert Assert.AreSame(foreshoreProfile, result); mockRepository.VerifyAll(); }
public void Import_ValidConfigurationInvalidData_LogMessageAndContinueImport(string file, string expectedErrorMessage) { // Setup string filePath = Path.Combine(importerPath, file); var calculationGroup = new CalculationGroup(); var structure = new TestClosingStructure("kunstwerk1", "kunstwerk1"); var foreshoreProfile = new TestForeshoreProfile("profiel 1"); var importer = new ClosingStructuresCalculationConfigurationImporter(filePath, calculationGroup, Enumerable.Empty <HydraulicBoundaryLocation>(), new ForeshoreProfile[] { foreshoreProfile }, new ClosingStructure[] { structure }); var successful = false; // Call void Call() => successful = importer.Import(); // Assert string expectedMessage = $"{expectedErrorMessage} Berekening 'Berekening 1' is overgeslagen."; TestHelper.AssertLogMessageWithLevelIsGenerated(Call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 2); Assert.IsTrue(successful); CollectionAssert.IsEmpty(calculationGroup.Children); }
public void UpdateForeshoreProfilesWithImportedData_ForeshoreProfilePropertiesChanged_UpdateRelevantProperties( ForeshoreProfile readForeshoreProfile) { // Setup var profileToBeUpdated = new TestForeshoreProfile(); var targetCollection = new ForeshoreProfileCollection(); targetCollection.AddRange(new[] { profileToBeUpdated }, sourceFilePath); var strategy = new ForeshoreProfileUpdateDataStrategy(new TestCalculatableFailureMechanism(), targetCollection); // Call strategy.UpdateForeshoreProfilesWithImportedData(new[] { readForeshoreProfile }, sourceFilePath); // Assert Assert.AreEqual(1, targetCollection.Count); Assert.AreSame(profileToBeUpdated, targetCollection[0]); AssertForeshoreProfile(readForeshoreProfile, profileToBeUpdated); }
public void UpdateForeshoreProfilesWithImportedData_MultipleCalculationsWithOutputAndProfile_UpdatesCalculationWithUpdatedProfile() { // Setup var affectedProfile = new TestForeshoreProfile("Name", "Updated ID"); TestCalculationWithForeshoreProfile affectedCalculation = TestCalculationWithForeshoreProfile.CreateCalculationWithOutput(affectedProfile); ForeshoreProfile profileToUpdateFrom = DeepCloneAndModify(affectedProfile); const string unaffectedProfileId = "Unaffected ID"; const string unaffectedProfileName = "Name"; var unaffectedProfile = new TestForeshoreProfile(unaffectedProfileName, unaffectedProfileId); TestCalculationWithForeshoreProfile unaffectedCalculation = TestCalculationWithForeshoreProfile.CreateCalculationWithOutput(unaffectedProfile); var foreshoreProfiles = new ForeshoreProfileCollection(); TestForeshoreProfile[] originalForeshoreProfiles = { affectedProfile, unaffectedProfile }; foreshoreProfiles.AddRange(originalForeshoreProfiles, sourceFilePath); var failureMechanism = new TestCalculatableFailureMechanism(new[] { affectedCalculation, unaffectedCalculation }); var strategy = new ForeshoreProfileUpdateDataStrategy(failureMechanism, foreshoreProfiles); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateForeshoreProfilesWithImportedData(new[] { new TestForeshoreProfile(unaffectedProfileName, unaffectedProfileId), profileToUpdateFrom }, sourceFilePath); // Assert Assert.IsTrue(unaffectedCalculation.HasOutput); Assert.AreSame(unaffectedProfile, unaffectedCalculation.InputParameters.ForeshoreProfile); Assert.IsFalse(affectedCalculation.HasOutput); Assert.AreSame(affectedProfile, affectedCalculation.InputParameters.ForeshoreProfile); CollectionAssert.AreEquivalent(originalForeshoreProfiles, foreshoreProfiles); CollectionAssert.AreEquivalent(new IObservable[] { affectedCalculation, affectedCalculation.InputParameters, affectedProfile, foreshoreProfiles }, affectedObjects); }
public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() { // Setup const int numberOfChangedProperties = 6; var observer = mockRepository.StrictMock <IObserver>(); observer.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); mockRepository.ReplayAll(); var calculation = new StructuresCalculation <SimpleStructureInput> { InputParameters = { Structure = new TestStructure() } }; var inputContext = new SimpleInputContext(calculation.InputParameters, calculation, failureMechanism, assessmentSection); var properties = new SimpleStructuresInputProperties( inputContext, new StructuresInputBaseProperties <TestStructure, SimpleStructureInput, StructuresCalculation <SimpleStructureInput>, IFailureMechanism> .ConstructionProperties(), new ObservablePropertyChangeHandler(inputContext.Calculation, calculation.InputParameters)); inputContext.Attach(observer); var random = new Random(100); double newStructureNormalOrientation = random.NextDouble(); const bool newShouldIllustrationPointsBeCalculated = true; var newStructure = new TestStructure(); ForeshoreProfile newForeshoreProfile = new TestForeshoreProfile(); HydraulicBoundaryLocation newHydraulicBoundaryLocation = CreateHydraulicBoundaryLocation(); var newSelectableHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(newHydraulicBoundaryLocation, null); // Call properties.Structure = newStructure; properties.StructureNormalOrientation = (RoundedDouble)newStructureNormalOrientation; properties.FailureProbabilityStructureWithErosion = 1e-2; properties.SelectedHydraulicBoundaryLocation = newSelectableHydraulicBoundaryLocation; properties.ForeshoreProfile = newForeshoreProfile; properties.ShouldIllustrationPointsBeCalculated = newShouldIllustrationPointsBeCalculated; // Assert Assert.AreSame(newStructure, properties.Structure); Assert.AreEqual(newStructureNormalOrientation, properties.StructureNormalOrientation, properties.StructureNormalOrientation.GetAccuracy()); Assert.AreEqual(0.01, properties.FailureProbabilityStructureWithErosion); Assert.AreSame(newHydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); Assert.AreSame(newForeshoreProfile, properties.ForeshoreProfile); Assert.AreEqual(newShouldIllustrationPointsBeCalculated, properties.ShouldIllustrationPointsBeCalculated); mockRepository.VerifyAll(); }
public void UpdateForeshoreProfilesWithImportedData_CalculationWithOutputAndForeshoreProfileUpdatedWithProfileWithoutGeometry_UpdatesCalculation() { // Setup const string id = "profile ID"; IEnumerable <Point2D> geometry = new[] { new Point2D(1, 2), new Point2D(3, 4) }; var affectedProfile = new TestForeshoreProfile(id, geometry); TestCalculationWithForeshoreProfile affectedCalculation = TestCalculationWithForeshoreProfile.CreateCalculationWithOutput(affectedProfile); affectedCalculation.InputParameters.UseForeshore = true; var profileToUpdateFrom = new TestForeshoreProfile(id, Enumerable.Empty <Point2D>()); var foreshoreProfiles = new ForeshoreProfileCollection(); TestForeshoreProfile[] originalForeshoreProfiles = { affectedProfile }; foreshoreProfiles.AddRange(originalForeshoreProfiles, sourceFilePath); var failureMechanism = new TestCalculatableFailureMechanism(new[] { affectedCalculation }); var strategy = new ForeshoreProfileUpdateDataStrategy(failureMechanism, foreshoreProfiles); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateForeshoreProfilesWithImportedData(new[] { profileToUpdateFrom }, sourceFilePath); // Assert Assert.IsFalse(affectedCalculation.HasOutput); Assert.IsFalse(affectedCalculation.InputParameters.UseForeshore); AssertForeshoreProfile(affectedProfile, profileToUpdateFrom); CollectionAssert.AreEquivalent(new IObservable[] { affectedCalculation, affectedCalculation.InputParameters, affectedProfile, foreshoreProfiles }, affectedObjects); }
public void ForeshoreProfile_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged() { // Setup ForeshoreProfile newProfile = new TestForeshoreProfile(new Point2D(0.0, 0.0)); var newValue = new DataGridViewComboBoxItemWrapper <ForeshoreProfile>(newProfile); var calculation = new StructuresCalculationScenario <HeightStructuresInput>(); // Call & Assert SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.ForeshoreProfile = newValue, calculation); }
public void UpdateForeshoreProfilesWithImportedData_WithCurrentCollectionAndImportedCollectionHasPartialOverlap_UpdatesTargetDataCollection() { // Setup var commonName = "Name"; var foreshoreProfileToBeUpdated = new TestForeshoreProfile(commonName, "Updated ID"); var foreshoreProfileToBeRemoved = new TestForeshoreProfile(commonName, "Removed ID"); var foreshoreProfiles = new ForeshoreProfileCollection(); foreshoreProfiles.AddRange(new[] { foreshoreProfileToBeUpdated, foreshoreProfileToBeRemoved }, sourceFilePath); ForeshoreProfile foreshoreProfileToUpdateFrom = DeepCloneAndModify(foreshoreProfileToBeUpdated); var foreshoreProfileToBeAdded = new TestForeshoreProfile(commonName, "Added ID"); ForeshoreProfile[] importedForeshoreProfiles = { foreshoreProfileToUpdateFrom, foreshoreProfileToBeAdded }; var strategy = new ForeshoreProfileUpdateDataStrategy(new TestCalculatableFailureMechanism(), foreshoreProfiles); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateForeshoreProfilesWithImportedData(importedForeshoreProfiles, sourceFilePath); // Assert Assert.AreEqual(2, foreshoreProfiles.Count); CollectionAssert.AreEqual(new[] { foreshoreProfileToBeUpdated, foreshoreProfileToBeAdded }, foreshoreProfiles); ForeshoreProfile updatedForeshoreProfile = foreshoreProfiles[0]; Assert.AreSame(foreshoreProfileToBeUpdated, updatedForeshoreProfile); AssertForeshoreProfile(foreshoreProfileToUpdateFrom, updatedForeshoreProfile); ForeshoreProfile addedForeshoreProfile = foreshoreProfiles[1]; Assert.AreSame(foreshoreProfileToBeAdded, addedForeshoreProfile); AssertForeshoreProfile(foreshoreProfileToBeAdded, addedForeshoreProfile); CollectionAssert.AreEquivalent(new IObservable[] { foreshoreProfileToBeUpdated, foreshoreProfiles }, affectedObjects); }
public void Text_Always_ReturnForeshoreProfileName() { // Setup const string profileName = "Random profile name"; ForeshoreProfile foreshoreProfile = new TestForeshoreProfile(profileName, "id"); // Call string text = info.Text(foreshoreProfile); // Assert Assert.AreEqual(profileName, text); }
public void ClearForeshoreProfile_CalculationsWithForeshoreProfile_ClearForeshoreProfileAndReturnAffectedInputs() { // Setup var foreshoreProfileToBeRemoved = new TestForeshoreProfile(new Point2D(0, 0)); var foreshoreProfile = new TestForeshoreProfile(new Point2D(1, 1)); var calculation1 = new StructuresCalculation <TestStructuresInput> { InputParameters = { ForeshoreProfile = foreshoreProfile } }; var calculation2 = new StructuresCalculation <TestStructuresInput> { InputParameters = { ForeshoreProfile = foreshoreProfileToBeRemoved } }; var calculation3 = new StructuresCalculation <TestStructuresInput> { InputParameters = { ForeshoreProfile = foreshoreProfileToBeRemoved }, Output = new TestStructuresOutput() }; StructuresCalculation <TestStructuresInput>[] calculations = { calculation1, calculation2, calculation3 }; // Call IEnumerable <IObservable> affectedObjects = RiskeerCommonDataSynchronizationService.ClearForeshoreProfile <TestStructuresInput, TestStructure>( calculations, foreshoreProfileToBeRemoved); // Assert Assert.IsNull(calculation2.InputParameters.ForeshoreProfile); Assert.IsNull(calculation3.InputParameters.ForeshoreProfile); Assert.IsFalse(calculation3.HasOutput); Assert.IsNotNull(calculation1.InputParameters.ForeshoreProfile); CollectionAssert.AreEqual(new IObservable[] { calculation2.InputParameters, calculation3, calculation3.InputParameters }, affectedObjects); }
public void UpdateForeshoreProfilesWithImportedData_CalculationsWithForeshoreProfilesAndOutput_CalculationUpdatedAndReturnsAffectedData() { // Setup var foreshoreProfile = new TestForeshoreProfile(); TestCalculationWithForeshoreProfile calculationWithForeshoreProfileAndOutput = TestCalculationWithForeshoreProfile.CreateCalculationWithOutput(foreshoreProfile); TestCalculationWithForeshoreProfile calculationWithForeshoreProfile = TestCalculationWithForeshoreProfile.CreateCalculationWithoutOutput(foreshoreProfile); TestCalculationWithForeshoreProfile calculationWithoutForeshoreProfile = TestCalculationWithForeshoreProfile.CreateDefaultCalculation(); var failureMechanism = new TestCalculatableFailureMechanism(new[] { calculationWithForeshoreProfileAndOutput, calculationWithForeshoreProfile, calculationWithoutForeshoreProfile }); var foreshoreProfiles = new ForeshoreProfileCollection(); foreshoreProfiles.AddRange(new[] { foreshoreProfile }, sourceFilePath); TestCalculationWithForeshoreProfile[] calculationsWithForeshoreProfile = { calculationWithForeshoreProfileAndOutput, calculationWithForeshoreProfile }; var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism, foreshoreProfiles); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateForeshoreProfilesWithImportedData(Enumerable.Empty <ForeshoreProfile>(), sourceFilePath); // Assert CollectionAssert.IsEmpty(foreshoreProfiles); Assert.IsFalse(calculationWithForeshoreProfileAndOutput.HasOutput); Assert.IsTrue(calculationsWithForeshoreProfile.All(calc => calc.InputParameters.ForeshoreProfile == null)); IEnumerable <IObservable> expectedAffectedObjects = calculationsWithForeshoreProfile.Select(calc => calc.InputParameters) .Concat(new IObservable[] { foreshoreProfiles, calculationWithForeshoreProfileAndOutput }); CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects); }
public void Data_SetForeshoreProfileInstanceWithoutBreakWater_ReturnCorrectPropertyValues() { // Setup var foreshoreProfile = new TestForeshoreProfile(); var properties = new BreakWaterProperties(); // Call properties.Data = foreshoreProfile; // Assert Assert.IsFalse(properties.HasBreakWater); }
public void Create_WithoutCollector_ThrowsArgumentNullException() { // Setup var foreshoreProfile = new TestForeshoreProfile(); // Call TestDelegate test = () => foreshoreProfile.Create(null, 0); // Assert string parameterName = Assert.Throws <ArgumentNullException>(test).ParamName; Assert.AreEqual("registry", parameterName); }
public void Data_SetForeshoreProfileInstanceWithBreakWater_ReturnCorrectPropertyValues() { // Setup var foreshoreProfile = new TestForeshoreProfile(new BreakWater(BreakWaterType.Wall, 10.0)); var properties = new BreakWaterProperties(); // Call properties.Data = foreshoreProfile; // Assert Assert.IsTrue(properties.HasBreakWater); Assert.AreEqual(BreakWaterType.Wall, properties.BreakWaterType); Assert.AreEqual(10.0, properties.BreakWaterHeight.Value); }
public void Create_WithBreakWater_ReturnsForeshoreProfileWithBreakWaterPropertiesSet() { // Setup double height = new Random(21).NextDouble(); const BreakWaterType breakWaterType = BreakWaterType.Caisson; var foreshoreProfile = new TestForeshoreProfile(new BreakWater(breakWaterType, height)); var registry = new PersistenceRegistry(); // Call ForeshoreProfileEntity entity = foreshoreProfile.Create(registry, 0); // Assert Assert.IsNotNull(entity); Assert.AreEqual((int)breakWaterType, entity.BreakWaterType); Assert.AreEqual(height, entity.BreakWaterHeight, foreshoreProfile.BreakWater.Height.GetAccuracy()); }
public void Create_ForeshoreProfileAlreadyRegistered_ReturnRegisteredEntity() { // Setup var foreshoreProfile = new TestForeshoreProfile(); var registry = new PersistenceRegistry(); ForeshoreProfileEntity entity1 = foreshoreProfile.Create(registry, 0); // Precondition: Assert.IsTrue(registry.Contains(foreshoreProfile)); // Call ForeshoreProfileEntity entity2 = foreshoreProfile.Create(registry, 0); // Assert Assert.AreSame(entity1, entity2); }
public void GivenViewWithForeshoreProfileData_WhenForeshoreProfileUpdatedAndNotified_ThenMapDataUpdated() { // Given var foreshoreProfile = new TestForeshoreProfile("originalProfile ID", new[] { new Point2D(0, 0), new Point2D(1, 1) }); var failureMechanism = new StabilityStoneCoverFailureMechanism(); failureMechanism.ForeshoreProfiles.AddRange(new[] { foreshoreProfile }, "path"); StabilityStoneCoverFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub()); IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl; var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); observers[foreshoreProfileObserverIndex].Expect(obs => obs.UpdateObserver()); mocks.ReplayAll(); MapData foreshoreProfileData = map.Data.Collection.ElementAt(foreshoreProfilesIndex); // Precondition MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); // When var foreshoreProfileToUpdateFrom = new TestForeshoreProfile("originalProfile ID", new[] { new Point2D(2, 2), new Point2D(3, 3) }); foreshoreProfile.CopyProperties(foreshoreProfileToUpdateFrom); foreshoreProfile.NotifyObservers(); // Then MapDataTestHelper.AssertForeshoreProfilesMapData(failureMechanism.ForeshoreProfiles, foreshoreProfileData); mocks.VerifyAll(); }
public void UpdateForeshoreProfilesWithImportedData_MultipleCalculationsWithSameReference_OnlyReturnsDistinctCalculations() { // Setup var affectedProfile = new TestForeshoreProfile("Name", "Updated ID"); TestCalculationWithForeshoreProfile affectedCalculation = TestCalculationWithForeshoreProfile.CreateCalculationWithOutput(affectedProfile); ForeshoreProfile profileToUpdateFrom = DeepCloneAndModify(affectedProfile); TestCalculationWithForeshoreProfile calculationSameReference = affectedCalculation; var foreshoreProfiles = new ForeshoreProfileCollection(); TestForeshoreProfile[] originalForeshoreProfiles = { affectedProfile }; foreshoreProfiles.AddRange(originalForeshoreProfiles, sourceFilePath); var failureMechanism = new TestCalculatableFailureMechanism(new[] { affectedCalculation, calculationSameReference }); var strategy = new ForeshoreProfileUpdateDataStrategy(failureMechanism, foreshoreProfiles); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateForeshoreProfilesWithImportedData(new[] { profileToUpdateFrom }, sourceFilePath); // Assert CollectionAssert.AreEquivalent(new IObservable[] { affectedCalculation, affectedCalculation.InputParameters, affectedProfile, foreshoreProfiles }, affectedObjects); }
public void SynchronizeForeshoreProfileInput_ChangedForeshoreProfile_ExpectedValues() { // Setup var differentProfile = new TestForeshoreProfile(true); var input = new SimpleStructuresInput { ForeshoreProfile = new TestForeshoreProfile() }; input.ForeshoreProfile.CopyProperties(differentProfile); // Precondition AssertForeshoreProfilePropertiesOfInput(new TestForeshoreProfile(), input); // Call input.SynchronizeForeshoreProfileInput(); // Assert AssertForeshoreProfilePropertiesOfInput(differentProfile, input); }
public void Read_EntityWithForeshoreProfileEntity_ReturnCalculationWithForeshoreProfile() { // Setup var profile = new TestForeshoreProfile(); var profileEntity = new ForeshoreProfileEntity(); var entity = new StabilityPointStructuresCalculationEntity { ForeshoreProfileEntity = profileEntity, ScenarioContribution = 0 }; var collector = new ReadConversionCollector(); collector.Read(profileEntity, profile); // Call StructuresCalculationScenario <StabilityPointStructuresInput> calculation = entity.Read(collector); // Assert Assert.AreSame(profile, calculation.InputParameters.ForeshoreProfile); }
public void Create_WithGeometry_ReturnsForeshoreProfileWithGeometryStringSet() { // Setup int order = new Random(21).Next(); var geometryPoints = new[] { new Point2D(0, 0), new Point2D(0, 0) }; var foreshoreProfile = new TestForeshoreProfile(geometryPoints); var registry = new PersistenceRegistry(); // Call ForeshoreProfileEntity entity = foreshoreProfile.Create(registry, order); // Assert Assert.IsNotNull(entity); string expectedXml = new Point2DCollectionXmlSerializer().ToXml(geometryPoints); Assert.AreEqual(expectedXml, entity.GeometryXml); }
public void PropertyAttributes_SetForeshoreProfileInstanceWithBreakWater_ReturnExpectedValues() { // Setup var foreshoreProfile = new TestForeshoreProfile(new BreakWater(BreakWaterType.Caisson, 10.0)); // Call var properties = new BreakWaterProperties { Data = foreshoreProfile }; // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(3, dynamicProperties.Count); PropertyDescriptor useBreakWaterProperty = dynamicProperties[0]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(useBreakWaterProperty, "Misc", "Aanwezig", "Is er een dam aanwezig?", true); PropertyDescriptor breakWaterTypeProperty = dynamicProperties[1]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(breakWaterTypeProperty, "Misc", "Type", "Het type van de dam.", true); PropertyDescriptor breakWaterHeightProperty = dynamicProperties[2]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(breakWaterHeightProperty, "Misc", "Hoogte [m+NAP]", "De hoogte van de dam.", true); }
public void Import_UseForeshoreFalseButProfileWithoutForeshoreGeometry_DataAddedToModel() { // Setup string filePath = Path.Combine(path, "validConfigurationCalculationUseForeshoreFalseForeshoreProfileWithoutGeometry.xml"); var calculationGroup = new CalculationGroup(); var foreshoreProfile = new TestForeshoreProfile("Voorlandprofiel"); var importer = new TestWaveConditionsCalculationConfigurationImporter( filePath, calculationGroup, Enumerable.Empty <HydraulicBoundaryLocation>(), new[] { foreshoreProfile }, new FailureMechanismContribution(0.1, 0.1), Enumerable.Empty <HydraulicBoundaryLocationCalculationsForTargetProbability>()); // Call bool successful = importer.Import(); // Assert Assert.IsTrue(successful); var expectedCalculation = new TestTargetTestWaveConditionsCalculation { Name = "Berekening 1", InputParameters = { UseForeshore = false, Orientation = (RoundedDouble)0, ForeshoreProfile = foreshoreProfile, WaterLevelType = WaveConditionsInputWaterLevelType.MaximumAllowableFloodingProbability } }; Assert.AreEqual(1, calculationGroup.Children.Count); AssertWaveConditionsCalculation(expectedCalculation, (ICalculation <WaveConditionsInput>)calculationGroup.Children[0]); }
public void Read_EntityWithForeshoreProfileInCollector_CalculationHasAlreadyReadForeshoreProfile() { // Setup var foreshoreProfile = new TestForeshoreProfile(); var foreshoreProfileEntity = new ForeshoreProfileEntity { GeometryXml = new Point2DCollectionXmlSerializer().ToXml(Enumerable.Empty <Point2D>()) }; var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity { ForeshoreProfileEntity = foreshoreProfileEntity }; var collector = new ReadConversionCollector(); collector.Read(foreshoreProfileEntity, foreshoreProfile); // Call WaveImpactAsphaltCoverWaveConditionsCalculation calculation = entity.Read(collector); // Assert Assert.AreSame(foreshoreProfile, calculation.InputParameters.ForeshoreProfile); }
public void Data_SetForeshoreProfileInstanceWithData_ReturnCorrectPropertyValues() { // Setup var foreshoreProfile = new TestForeshoreProfile(new[] { new Point2D(0, 0), new Point2D(1, 1) }); var properties = new ForeshoreGeometryProperties(); // Call properties.Data = foreshoreProfile; // Assert var expectedCoordinates = new[] { new Point2D(0, 0), new Point2D(1, 1) }; CollectionAssert.AreEqual(expectedCoordinates, properties.Coordinates); }
public void UpdateForeshoreProfilesWithImportedData_CalculationWithOutputAssignedToRemovedProfile_UpdatesCalculation() { // Setup var profileToBeRemoved = new TestForeshoreProfile("Name", "Removed ID"); TestCalculationWithForeshoreProfile calculation = TestCalculationWithForeshoreProfile.CreateCalculationWithOutput(profileToBeRemoved); var foreshoreProfiles = new ForeshoreProfileCollection(); foreshoreProfiles.AddRange(new[] { profileToBeRemoved }, sourceFilePath); var failureMechanism = new TestCalculatableFailureMechanism(new[] { calculation }); var strategy = new ForeshoreProfileUpdateDataStrategy(failureMechanism, foreshoreProfiles); // Call IEnumerable <IObservable> affectedObjects = strategy.UpdateForeshoreProfilesWithImportedData(Enumerable.Empty <ForeshoreProfile>(), sourceFilePath); // Assert Assert.IsFalse(calculation.HasOutput); Assert.IsNull(calculation.InputParameters.ForeshoreProfile); CollectionAssert.IsEmpty(foreshoreProfiles); CollectionAssert.AreEquivalent(new IObservable[] { calculation, calculation.InputParameters, foreshoreProfiles }, affectedObjects); }