Index: DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/IntersectionOnShapesTest.cs =================================================================== diff -u -r4070 -r4255 --- DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/IntersectionOnShapesTest.cs (.../IntersectionOnShapesTest.cs) (revision 4070) +++ DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/IntersectionOnShapesTest.cs (.../IntersectionOnShapesTest.cs) (revision 4255) @@ -41,7 +41,7 @@ const string crossSectionFile = @"..\..\..\..\..\data\Dam\Waterboards\HHNK\ShapeFiles\Crosssection.shp"; const string trafficFile = @"..\..\..\..\..\data\Dam\Waterboards\HHNK\ShapeFiles\TrafficLoad.shp"; - FindAllIntersectionsDotSpatial(crossSectionFile, trafficFile); + FindAllIntersectionsDotSpatial(crossSectionFile, trafficFile, 5543, 8329, 5602); } [Test] @@ -52,7 +52,7 @@ const string crossSectionFile = @"..\..\..\..\..\data\Dam\Waterboards\HHNK\ShapeFiles\Crosssection.shp"; const string polderLevelFile = @"..\..\..\..\..\data\Dam\Waterboards\HHNK\ShapeFiles\PolderLevel.shp"; - FindAllIntersectionsDotSpatial(crossSectionFile, polderLevelFile); + FindAllIntersectionsDotSpatial(crossSectionFile, polderLevelFile, 5543, 4393, 12469); } [Test] @@ -61,7 +61,7 @@ const string crossSectionFile = @"..\..\..\..\..\data\Dam\Waterboards\HHNK\ShapeFiles\Crosssection.shp"; const string trafficFile = @"..\..\..\..\..\data\Dam\Waterboards\HHNK\ShapeFiles\TrafficLoad.shp"; - FindFirstIntersectionDotSpatial(crossSectionFile, trafficFile); + FindFirstIntersectionDotSpatial(crossSectionFile, trafficFile, 5543, 8329, 1); } [Test] @@ -71,13 +71,14 @@ const string polderLevelFile = @"..\..\..\..\..\data\Dam\Waterboards\HHNK\ShapeFiles\PolderLevel.shp"; Debug.WriteLine("--- DotSpatial ---"); - FindFirstIntersectionDotSpatial(crossSectionFile, polderLevelFile); + FindFirstIntersectionDotSpatial(crossSectionFile, polderLevelFile, 5543, 4393, 2); Debug.WriteLine("--- NetTopologySuite ---"); - FindFirstIntersectionNetTopology(crossSectionFile, polderLevelFile); + FindFirstIntersectionNetTopology(crossSectionFile, polderLevelFile, 5543, 4393, 2); } - private void FindAllIntersectionsDotSpatial(string sourceFile, string targetFile) + private void FindAllIntersectionsDotSpatial(string sourceFile, string targetFile, + int expectedNumberOfSourceSections, int expectedNumberOfTargets, int expectedIntersections) { IFeatureSet crossSectionFeatureSet = FeatureSet.Open(sourceFile); IFeatureSet trafficLoadFeatureSet = FeatureSet.Open(targetFile); @@ -98,15 +99,16 @@ DateTime finish = DateTime.Now; TimeSpan duration = finish - start; - - Debug.WriteLine("Number of source sections: " + crossSectionFeatureSet.Features.Count); - Debug.WriteLine("Number of targets: " + trafficLoadFeatureSet.Features.Count); - Debug.WriteLine("Number of intersections: " + intersections); + + Assert.That(crossSectionFeatureSet.Features.Count, Is.EqualTo(expectedNumberOfSourceSections)); + Assert.That(trafficLoadFeatureSet.Features.Count, Is.EqualTo(expectedNumberOfTargets)); + Assert.That(intersections, Is.EqualTo(expectedIntersections)); Debug.WriteLine("Seconds: " + duration.TotalSeconds); Debug.WriteLine("Seconds per intersection: " + duration.TotalSeconds / (trafficLoadFeatureSet.Features.Count * crossSectionFeatureSet.Features.Count)); } - private void FindFirstIntersectionDotSpatial(string sourceFile, string targetFile) + private void FindFirstIntersectionDotSpatial(string sourceFile, string targetFile, + int expectedNumberOfSourceSections, int expectedNumberOfTargets, int expectedIntersections) { IFeatureSet crossSectionFeatureSet = FeatureSet.Open(sourceFile); IFeatureSet trafficLoadFeatureSet = FeatureSet.Open(targetFile); @@ -127,14 +129,16 @@ DateTime finish = DateTime.Now; TimeSpan duration = finish - start; - Debug.WriteLine("Number of source sections: 1"); - Debug.WriteLine("Number of targets: " + trafficLoadFeatureSet.Features.Count); + Assert.That(crossSectionFeatureSet.Features.Count, Is.EqualTo(expectedNumberOfSourceSections)); + Assert.That(trafficLoadFeatureSet.Features.Count, Is.EqualTo(expectedNumberOfTargets)); + Assert.That(intersections, Is.EqualTo(expectedIntersections)); Debug.WriteLine("Number of intersections: " + intersections); Debug.WriteLine("Seconds: " + duration.TotalSeconds); Debug.WriteLine("Seconds per intersection: " + duration.TotalSeconds / trafficLoadFeatureSet.Features.Count); } - private void FindFirstIntersectionNetTopology(string sourceFile, string targetFile) + private void FindFirstIntersectionNetTopology(string sourceFile, string targetFile, + int expectedNumberOfSourceSections, int expectedNumberOfTargets, int expectedIntersections) { IEnumerable crossSectionFeatures = NtsFeature.Read(sourceFile); IEnumerable trafficLoadFeatures = NtsFeature.Read(targetFile); @@ -143,9 +147,6 @@ var intersections = 0; - //if (featureToTest.IsWithin(feature) || featureToTest.IsTouching(feature)) line-polygon - //if (feature.IsIntersecting(featureToTest)) line-line - NtsFeature crossSectionFeature = crossSectionFeatures.First(); foreach (NtsFeature trafficLoadFeature in trafficLoadFeatures) { @@ -157,10 +158,10 @@ DateTime finish = DateTime.Now; TimeSpan duration = finish - start; - - Debug.WriteLine("Number of source sections: 1"); - Debug.WriteLine("Number of targets: " + trafficLoadFeatures.Count()); - Debug.WriteLine("Number of intersections: " + intersections); + + Assert.That(crossSectionFeatures.Count(), Is.EqualTo(expectedNumberOfSourceSections)); + Assert.That(trafficLoadFeatures.Count(), Is.EqualTo(expectedNumberOfTargets)); + Assert.That(intersections, Is.EqualTo(expectedIntersections)); Debug.WriteLine("Seconds: " + duration.TotalSeconds); Debug.WriteLine("Seconds per intersection: " + duration.TotalSeconds / trafficLoadFeatures.Count()); } Index: DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Memoryleaks/DamMemoryLeakTests.cs =================================================================== diff -u -r4070 -r4255 --- DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Memoryleaks/DamMemoryLeakTests.cs (.../DamMemoryLeakTests.cs) (revision 4070) +++ DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Memoryleaks/DamMemoryLeakTests.cs (.../DamMemoryLeakTests.cs) (revision 4255) @@ -29,6 +29,7 @@ namespace Deltares.Dam.Tests.Memoryleaks { + [TestFixture] public class DamMemoryLeakTests : MemoryLeakTestBase { [Test] Index: DamClients/DamUI/trunk/src/Dam/Forms/DamSpatialEditorDecorator.cs =================================================================== diff -u -r4070 -r4255 --- DamClients/DamUI/trunk/src/Dam/Forms/DamSpatialEditorDecorator.cs (.../DamSpatialEditorDecorator.cs) (revision 4070) +++ DamClients/DamUI/trunk/src/Dam/Forms/DamSpatialEditorDecorator.cs (.../DamSpatialEditorDecorator.cs) (revision 4255) @@ -389,11 +389,9 @@ { for (var i = 0; i < GeometryProbabilitiesCount; i++) { - if (csvExportData != null && - GeometryProbabilities[i].SoilGeometryName == csvExportData.StabilityProfileName) + if (GeometryProbabilities[i].SoilGeometryName == csvExportData.StabilityProfileName) { - CurrentSoilProfile = - locationJob.Location.GetSoilSurfaceProfile(FailureMechanismType, i, out probability); + CurrentSoilProfile = locationJob.Location.GetSoilSurfaceProfile(FailureMechanismType, i, out probability); index = i; } } @@ -532,15 +530,9 @@ /// private void UpdateRedesignedSurfaceLine() { - if (csvExportData != null) + if ((csvExportData != null) && (csvExportData.AnalysisType == AnalysisType.AdaptGeometry) && (csvExportData.RedesignedSurfaceLine2 != null)) { - if (csvExportData.AnalysisType == AnalysisType.AdaptGeometry) - { - if (csvExportData.RedesignedSurfaceLine2 != null) - { - ShowRedesignedSurfaceLine(csvExportData.RedesignedSurfaceLine2.Geometry); - } - } + ShowRedesignedSurfaceLine(csvExportData.RedesignedSurfaceLine2.Geometry); } } @@ -556,9 +548,9 @@ locationJob = (LocationJob) sender; LoadLocation(); } - else if (sender is CsvExportData) + else if (sender is CsvExportData data) { - csvExportData = (CsvExportData) sender; + csvExportData = data; LoadLocation(); } else if (sender is WaterBoard) @@ -588,13 +580,10 @@ locationJob = null; LoadLocation(); } - else if (sender is SoilSurfaceProfile) + else if (sender is SoilSurfaceProfile && locationJob != null && CurrentSoilProfile != null) { - if (locationJob != null && CurrentSoilProfile != null) - { - csvExportData = locationJob.GetDesignResultByProfileScenarioAndCalculationName(CurrentSoilProfile.SoilProfile.Name, - "1", LocationJob.CurrentCalculation); - } + csvExportData = locationJob.GetDesignResultByProfileScenarioAndCalculationName(CurrentSoilProfile.SoilProfile.Name, + "1", LocationJob.CurrentCalculation); } } Index: DamClients/DamUI/trunk/src/Dam/Forms/DamProjectCalculationOptionsPropertyControl.cs =================================================================== diff -u -r4239 -r4255 --- DamClients/DamUI/trunk/src/Dam/Forms/DamProjectCalculationOptionsPropertyControl.cs (.../DamProjectCalculationOptionsPropertyControl.cs) (revision 4239) +++ DamClients/DamUI/trunk/src/Dam/Forms/DamProjectCalculationOptionsPropertyControl.cs (.../DamProjectCalculationOptionsPropertyControl.cs) (revision 4255) @@ -76,9 +76,9 @@ } set { - if (value is DamFailureMechanismeCalculationSpecification) + if (value is DamFailureMechanismeCalculationSpecification specification) { - currentSpecification = (DamFailureMechanismeCalculationSpecification) value; + currentSpecification = specification; BindSupport.Assign(SearchMethodPanelControl, currentSpecification.FailureMechanismeParamatersMStab.MStabParameters); BindSupport.Assign(CircleDefinitionPanelControl, currentSpecification.FailureMechanismeParamatersMStab.MStabParameters.SlipCircleDefinition); } @@ -95,15 +95,14 @@ private void DataEventPublisher_OnAfterChange(object sender, PublishEventArgs e) { - if (sender is DamFailureMechanismeCalculationSpecification) + if (sender is DamFailureMechanismeCalculationSpecification specification) { - currentSpecification = (DamFailureMechanismeCalculationSpecification) sender; + currentSpecification = specification; SetSelectedDamCalculationSpecification(); } - if (sender is DamProject) + if (sender is DamProject pd) { - var pd = (DamProject) sender; currentSpecification = pd.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification; SetSelectedDamCalculationSpecification(); } Index: DamClients/DamUI/trunk/src/Dam/Forms/DesignCalculationPropertyControl.cs =================================================================== diff -u -r4070 -r4255 --- DamClients/DamUI/trunk/src/Dam/Forms/DesignCalculationPropertyControl.cs (.../DesignCalculationPropertyControl.cs) (revision 4070) +++ DamClients/DamUI/trunk/src/Dam/Forms/DesignCalculationPropertyControl.cs (.../DesignCalculationPropertyControl.cs) (revision 4255) @@ -70,16 +70,16 @@ private void DataEventPublisher_OnAfterChange(object sender, PublishEventArgs e) { - if (sender is LocationJobSymbol) + if (sender is LocationJobSymbol symbol) { - soilProfileName = ((LocationJobSymbol) sender).CurrentProfileName; - scenarioName = ((LocationJobSymbol) sender).CurrentScenarioName; - calculationName = ((LocationJobSymbol) sender).CurrentCalculation; + soilProfileName = symbol.CurrentProfileName; + scenarioName = symbol.CurrentScenarioName; + calculationName = symbol.CurrentCalculation; } - else if (sender is SoilProfile1D && locationJob != null) + else if (sender is SoilProfile1D profile1D && locationJob != null) { - string profname = ((SoilProfile1D) sender).Name; - result = locationJob.GetDesignResultByProfileScenarioAndCalculationName(profname, scenarioName, + string profileName = profile1D.Name; + result = locationJob.GetDesignResultByProfileScenarioAndCalculationName(profileName, scenarioName, calculationName); BindSupport.Assign(this, result); } @@ -95,15 +95,15 @@ } set { - if (value is CsvExportData) + if (value is CsvExportData data) { - result = value as CsvExportData; + result = data; locationJob = null; BindSupport.Assign(this, result); } - else if (value is LocationJob) + else if (value is LocationJob job) { - locationJob = (LocationJob) value; + locationJob = job; if (result == null || !result.LocationName.Equals((locationJob).Location.Name) || (locationJob).HasDesignScenarioResults == false || result.ProfileName != soilProfileName || result.ScenarioName != scenarioName || result.Calculation != calculationName) Index: DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Geometry.cs =================================================================== diff -u -r4070 -r4255 --- DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Geometry.cs (.../Geometry.cs) (revision 4070) +++ DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Geometry.cs (.../Geometry.cs) (revision 4255) @@ -31,14 +31,6 @@ { private string geomWktTestString; -// [Test] -// public void ClassIheritsSharpMapGeometry() -// { -// var geom = new Geometry(this.geomWktTestString); -// Assert.IsNotNull(geom); -// Assert.IsInstanceOfType(typeof(SharpGeom), geom); -// } - [Test] public void CanCreateGeometryFormWkt() { @@ -64,7 +56,7 @@ var geom = Feature.Create(geomWkt); Assert.IsNotNull(geom); Assert.IsNotNull(geom.Id); - Assert.AreNotEqual(geom.Id, Guid.Empty); + Assert.AreNotEqual(Guid.Empty, geom.Id); } [Test] @@ -76,7 +68,7 @@ const string testvalue = "testvalue"; geom.AddAttribute("test", testvalue); - Assert.AreEqual(geom["test"], testvalue); + Assert.AreEqual(testvalue, geom["test"]); } #region Setup Index: DamClients/DamUI/trunk/src/Dam/Forms/LocalizedMessageBox.cs =================================================================== diff -u -r4070 -r4255 --- DamClients/DamUI/trunk/src/Dam/Forms/LocalizedMessageBox.cs (.../LocalizedMessageBox.cs) (revision 4070) +++ DamClients/DamUI/trunk/src/Dam/Forms/LocalizedMessageBox.cs (.../LocalizedMessageBox.cs) (revision 4255) @@ -29,7 +29,7 @@ /// /// Summary description for LocalizedMessageBox /// - public class LocalizedMessageBox + public abstract class LocalizedMessageBox { public static DialogResult Show(object targetObject, string translationId) { Index: DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Importers/LineAttributeImporterTest.cs =================================================================== diff -u -r4070 -r4255 --- DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Importers/LineAttributeImporterTest.cs (.../LineAttributeImporterTest.cs) (revision 4070) +++ DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Importers/LineAttributeImporterTest.cs (.../LineAttributeImporterTest.cs) (revision 4255) @@ -125,43 +125,43 @@ var locations = new List { - new CsvImporterLocations.LocationRecord + new() { LocationId = "TPL_Hempolder_0010" }, - new CsvImporterLocations.LocationRecord + new() { LocationId = "TPL_Hempolder_0020" }, - new CsvImporterLocations.LocationRecord + new() { LocationId = "TPL_Hempolder_0030" }, - new CsvImporterLocations.LocationRecord + new() { LocationId = "TPL_Hempolder_0040" }, - new CsvImporterLocations.LocationRecord + new() { LocationId = "TPL_Hempolder_0050" }, - new CsvImporterLocations.LocationRecord + new() { LocationId = "TPL_Hempolder_0060" }, - new CsvImporterLocations.LocationRecord + new() { LocationId = "TPL_Hempolder_0070" }, - new CsvImporterLocations.LocationRecord + new() { LocationId = "TPL_Hempolder_0080" }, - new CsvImporterLocations.LocationRecord + new() { LocationId = "TPL_Hempolder_0090" }, - new CsvImporterLocations.LocationRecord + new() { LocationId = "TPL_Hempolder_0100" } @@ -183,16 +183,20 @@ mapping }; importer.Import(); + + Assert.That(locations.Count, Is.EqualTo(10)); + Assert.That(locations.First().LocationId, Is.EqualTo("TPL_Hempolder_0010")); + Assert.That(locations.Last().LocationId, Is.EqualTo("TPL_Hempolder_0100")); } [Test] public void Import_IntersectionFoundBetweenCrossSectionAndAttributeLine_ValuesFromAttributeLineAreSetOnTarget() { - const string locationID = "Test_Location_01"; + const string locationId = "Test_Location_01"; const double expectedValue = 5.7; var location = new CsvImporterLocations.LocationRecord { - LocationId = locationID + LocationId = locationId }; importer.Targets = new[] { @@ -202,7 +206,7 @@ importer.AttributeRepository = attributesRepository; LocationAttributeMapping crossSectionMapping = LocationShapeFileAttributeMap.GetAttributeMapping(LocationShapeFileAttributeMap.CrossSectionAttributId); - crossSection.AddAttribute(crossSectionMapping.Name, locationID); + crossSection.AddAttribute(crossSectionMapping.Name, locationId); Expect.Call(crossSectionRepository.Features).Return(new[] { crossSection @@ -234,11 +238,11 @@ [Test] public void Import_NoIntersectionFoundBetweenCrossSectionAndOutsideLine_ValuesFromAttributeLineAreNotSetOnTarget() { - const string locationID = "Test_Location_02"; + const string locationId = "Test_Location_02"; const double expectedValue = 5.7; var location = new CsvImporterLocations.LocationRecord { - LocationId = locationID, + LocationId = locationId, TrafficLoad = expectedValue }; importer.Targets = new[] @@ -249,7 +253,7 @@ importer.AttributeRepository = attributesRepository; LocationAttributeMapping crossSectionMapping = LocationShapeFileAttributeMap.GetAttributeMapping(LocationShapeFileAttributeMap.CrossSectionAttributId); - crossSection.AddAttribute(crossSectionMapping.Name, locationID); + crossSection.AddAttribute(crossSectionMapping.Name, locationId); Expect.Call(crossSectionRepository.Features).Return(new[] { crossSection @@ -281,11 +285,11 @@ [Test] public void Import_NoIntersectionFoundBetweenCrossSectionAndOutsideLine_ExceptionIsAdded() { - const string locationID = "Test_Location_02"; + const string locationId = "Test_Location_02"; const double expectedValue = 5.7; var location = new CsvImporterLocations.LocationRecord { - LocationId = locationID, + LocationId = locationId, TrafficLoad = expectedValue }; importer.Targets = new[] @@ -296,7 +300,7 @@ importer.AttributeRepository = attributesRepository; LocationAttributeMapping crossSectionMapping = LocationShapeFileAttributeMap.GetAttributeMapping(LocationShapeFileAttributeMap.CrossSectionAttributId); - crossSection.AddAttribute(crossSectionMapping.Name, locationID); + crossSection.AddAttribute(crossSectionMapping.Name, locationId); Expect.Call(crossSectionRepository.Features).Return(new[] { crossSection Index: DamClients/DamUI/trunk/src/Dam/Forms/DamProjectCalculationSpecificationPropertyControl.cs =================================================================== diff -u -r4109 -r4255 --- DamClients/DamUI/trunk/src/Dam/Forms/DamProjectCalculationSpecificationPropertyControl.cs (.../DamProjectCalculationSpecificationPropertyControl.cs) (revision 4109) +++ DamClients/DamUI/trunk/src/Dam/Forms/DamProjectCalculationSpecificationPropertyControl.cs (.../DamProjectCalculationSpecificationPropertyControl.cs) (revision 4255) @@ -54,13 +54,10 @@ private void DataEventPublisher_OnAfterChange(object sender, PublishEventArgs e) { var specification = sender as DamFailureMechanismeCalculationSpecification; - if (specification != null) + if (specification != null && damProjectCalculationSpecification != null) { - if (damProjectCalculationSpecification != null) - { - damProjectCalculationSpecification.CurrentSpecification = specification; - SetSelectedDamCalculationSpecification(); - } + damProjectCalculationSpecification.CurrentSpecification = specification; + SetSelectedDamCalculationSpecification(); } } @@ -69,8 +66,7 @@ DamFailureMechanismeCalculationSpecification selection = damProjectCalculationSpecification.CurrentSpecification; if (selection != null) { - selection.FailureMechanismeParamatersMStab.MStabParameters.SlipCircleDefinition.Specification = - selection; + selection.FailureMechanismeParamatersMStab.MStabParameters.SlipCircleDefinition.Specification = selection; BindSupport.Assign(damProjectCalculationOptionsPropertyControl1, selection); if (firstEdit) { @@ -81,25 +77,20 @@ if (selection.FailureMechanismSystemType != FailureMechanismSystemType.Piping && firstEdit) { // this is a hack to force update on ill placed edits. - Width = Width + 1; + Width += 1; firstEdit = false; } } } private void DataEventPublisher_OnSubSelectionChanged(object sender, PublishEventArgs e) { - if (((SelectionEventArgs) e).PropertyEditorReactionType == PropertyEditorReactionType.Ignore) + if (((SelectionEventArgs) e).PropertyEditorReactionType == PropertyEditorReactionType.Ignore && + sender is DamFailureMechanismeCalculationSpecification item && + damProjectCalculationSpecification.DamCalculationSpecifications.Contains(item)) { - var item = sender as DamFailureMechanismeCalculationSpecification; - if (item != null) - { - if (damProjectCalculationSpecification.DamCalculationSpecifications.Contains(item)) - { - damProjectCalculationSpecification.CurrentSpecification = item; - SetSelectedDamCalculationSpecification(); - } - } + damProjectCalculationSpecification.CurrentSpecification = item; + SetSelectedDamCalculationSpecification(); } } Index: DamClients/DamUI/trunk/src/Dam/Forms/DamNewProjectDialog.cs =================================================================== diff -u -r4070 -r4255 --- DamClients/DamUI/trunk/src/Dam/Forms/DamNewProjectDialog.cs (.../DamNewProjectDialog.cs) (revision 4070) +++ DamClients/DamUI/trunk/src/Dam/Forms/DamNewProjectDialog.cs (.../DamNewProjectDialog.cs) (revision 4255) @@ -195,16 +195,15 @@ private void OkButtonClick(object sender, EventArgs e) { // Check if specified file exists - if ((damNewProjectData.DamDataSourceFileName == "") || - (File.Exists(damNewProjectData.DamDataSourceFileName) != true)) + if ((damNewProjectData.DamDataSourceFileName == "") || !File.Exists(damNewProjectData.DamDataSourceFileName)) { LocalizedMessageBox.Show(this, "SelectValidFile"); DialogResult = DialogResult.None; return; } // Check if configuration file exists - if ((damNewProjectData.DamProjectType == DamProjectType.DamLiveConfiguration) && (!IsValidSensorConfigurationFilename(damNewProjectData.SensorConfigurationFileName))) + if ((damNewProjectData.DamProjectType == DamProjectType.DamLiveConfiguration) && !IsValidSensorConfigurationFilename(damNewProjectData.SensorConfigurationFileName)) { DialogResult = DialogResult.None; return; @@ -278,11 +277,11 @@ { // take projection from LocationID shapefile string damProjectFolder = Path.GetDirectoryName(sourceFileName); - DataSource shapeFileDataSource = dataSourceContainer.DataSourceList.FirstOrDefault(s => s.DataSourceType == DataSourceType.DataShapeFiles); + DataSource shapeFileDataSource = dataSourceContainer.DataSourceList.Find(s => s.DataSourceType == DataSourceType.DataShapeFiles); if (damProjectFolder != null && shapeFileDataSource != null) { string shapeFileFolder = Path.Combine(damProjectFolder, shapeFileDataSource.DataLocation); - DataAttribute shapeAttribute = dataSourceContainer.DataAttributes.FirstOrDefault(s => s.AttributeId.ToLower() == CsvColumnNames.LocationColumnName); + DataAttribute shapeAttribute = dataSourceContainer.DataAttributes.Find(s => s.AttributeId.ToLower() == CsvColumnNames.LocationColumnName); if (shapeAttribute != null) { string shapeFilePath = Path.Combine(shapeFileFolder, shapeAttribute.DataSource); Index: DamClients/DamUI/trunk/src/Dam/Forms/DamPlugin.cs =================================================================== diff -u -r4070 -r4255 --- DamClients/DamUI/trunk/src/Dam/Forms/DamPlugin.cs (.../DamPlugin.cs) (revision 4070) +++ DamClients/DamUI/trunk/src/Dam/Forms/DamPlugin.cs (.../DamPlugin.cs) (revision 4255) @@ -26,6 +26,7 @@ using System.Drawing; using System.IO; using System.Linq; +using System.Text; using System.Windows.Forms; using Deltares.Dam.Data; using Deltares.Dam.Data.DamEngineIo; @@ -653,7 +654,7 @@ mainForm.HelpMenu.InsertItem(aboutItem, manualItem); // Remove the link: Tools->License - BarItemLink licenseItemLink = mainForm.ToolsMenu.ItemLinks.Cast().Where(il => il.Item.Name.Equals("LicenseBarButton")).ToList().FirstOrDefault(); + BarItemLink licenseItemLink = mainForm.ToolsMenu.ItemLinks.Cast().First(il => il.Item.Name.Equals("LicenseBarButton")); mainForm.ToolsMenu.ItemLinks.Remove(licenseItemLink); BindSupport.Bind(panel, surfacelineExportItem, x => x.ExecuteSurfacelinesExport()); @@ -1321,17 +1322,18 @@ /// private void ShowErrorMessageBox(Exception e) { - string msg = e.Message + Environment.NewLine; + var stringBuilder = new StringBuilder(e.Message + Environment.NewLine); Exception exception = e.InnerException; while (exception != null) { - msg += exception.Message + Environment.NewLine; + + stringBuilder.AppendLine(exception.Message + Environment.NewLine); exception = exception.InnerException; } var args = new object[] { - msg + stringBuilder.ToString() }; LocalizedMessageBox.ShowError(this, "ErrorMessage", args); } @@ -1342,11 +1344,11 @@ /// private void ShowImportErrorMessage(Exception e) { - string msg = e.Message + Environment.NewLine; + var stringBuilder = new StringBuilder(e.Message + Environment.NewLine); Exception exception = e.InnerException; while (exception != null) { - msg += exception.Message + Environment.NewLine; + stringBuilder.Append(exception.Message + Environment.NewLine); exception = exception.InnerException; } @@ -1356,7 +1358,7 @@ damNewProjectData.DamDataSourceFileName, Environment.NewLine + Environment.NewLine, Environment.NewLine, - msg + stringBuilder.ToString() }; LocalizedMessageBox.ShowError(this, "ErrorImportingDataSourceFile", args); } Index: DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Importers/LocationShapeFileImporterTest.cs =================================================================== diff -u -r4070 -r4255 --- DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Importers/LocationShapeFileImporterTest.cs (.../LocationShapeFileImporterTest.cs) (revision 4070) +++ DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Importers/LocationShapeFileImporterTest.cs (.../LocationShapeFileImporterTest.cs) (revision 4255) @@ -34,7 +34,6 @@ [TestFixture] public class LocationShapeFileImporterTest { - private const string ShapeFileImportFolder = "TestFiles"; private ICollection locations; private LocationShapeFileImporter importer; private MockRepository mocks; @@ -44,8 +43,12 @@ [Test] public void Importer_GivenEmptyLocationList_ShouldNotThrow() { - var invalidImporter = new LocationShapeFileImporter(null, null); - mocks.ReplayAll(); + + Assert.DoesNotThrow(() => + { + _ = new LocationShapeFileImporter(null, null); + mocks.ReplayAll(); + }); } [Test] Index: DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/GeometryFileTest.cs =================================================================== diff -u -r4070 -r4255 --- DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/GeometryFileTest.cs (.../GeometryFileTest.cs) (revision 4070) +++ DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/GeometryFileTest.cs (.../GeometryFileTest.cs) (revision 4255) @@ -32,12 +32,6 @@ private string existingFile; [Test] - public void FileAcceptsEmptyLocation() - { - var file = new MockFile("", "test.tst"); - } - - [Test] public void FileReturnsValidFullPath() { const string fileName = "test.tst";