Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -r8404b9bd4e87e4a097a982ddccba6ecfa5aeec32 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 8404b9bd4e87e4a097a982ddccba6ecfa5aeec32) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -63,7 +63,6 @@ Properties\GlobalAssembly.cs - @@ -92,12 +91,19 @@ + + RingtoetsDBContext.tt + {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base + + {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} + Core.Common.Utils + {c90b77da-e421-43cc-b82e-529651bc21ac} Core.Common.Version Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Converter/ProjectEntityConverter.cs =================================================================== diff -u -r3a8bff057967bdb42389382472f6ce55789a0ced -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/Converter/ProjectEntityConverter.cs (.../ProjectEntityConverter.cs) (revision 3a8bff057967bdb42389382472f6ce55789a0ced) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Converter/ProjectEntityConverter.cs (.../ProjectEntityConverter.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -42,7 +42,7 @@ /// /// to convert. /// A new instance of , based on the properties of . - public static Project ProjectEntityToProject( ProjectEntity projectEntity ) + public static Project ProjectEntityToProject(ProjectEntity projectEntity) { var project = new Project { @@ -65,6 +65,5 @@ projectEntity.Description = project.Description; projectEntity.LastUpdated = new DateTime().Ticks; } - } -} +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Ringtoets.rt =================================================================== diff -u -r8404b9bd4e87e4a097a982ddccba6ecfa5aeec32 -r654d3a712eedbdeea718dc0448c5544f09e053cd Binary files differ Index: Application/Ringtoets/src/Application.Ringtoets.Storage/RingtoetsDBContext.Context.cs =================================================================== diff -u -r3a8bff057967bdb42389382472f6ce55789a0ced -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/RingtoetsDBContext.Context.cs (.../RingtoetsDBContext.Context.cs) (revision 3a8bff057967bdb42389382472f6ce55789a0ced) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/RingtoetsDBContext.Context.cs (.../RingtoetsDBContext.Context.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -27,5 +27,6 @@ } public virtual IDbSet ProjectEntities { get; set; } + public virtual IDbSet Versions { get; set; } } } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/RingtoetsDBContext.edmx =================================================================== diff -u -r0155f2f233aefc7951782b302e1398e02c00f298 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/RingtoetsDBContext.edmx (.../RingtoetsDBContext.edmx) (revision 0155f2f233aefc7951782b302e1398e02c00f298) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/RingtoetsDBContext.edmx (.../RingtoetsDBContext.edmx) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -4,7 +4,7 @@ - + @@ -14,15 +14,26 @@ + + + + + + + + + + + @@ -33,6 +44,15 @@ + + + + + + + + + @@ -49,6 +69,16 @@ + + + + + + + + + + @@ -64,7 +94,7 @@ - + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/RingtoetsDBContext.edmx.diagram =================================================================== diff -u -r0155f2f233aefc7951782b302e1398e02c00f298 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/RingtoetsDBContext.edmx.diagram (.../RingtoetsDBContext.edmx.diagram) (revision 0155f2f233aefc7951782b302e1398e02c00f298) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/RingtoetsDBContext.edmx.diagram (.../RingtoetsDBContext.edmx.diagram) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -6,6 +6,7 @@ + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs =================================================================== diff -u -r3a8bff057967bdb42389382472f6ce55789a0ced -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision 3a8bff057967bdb42389382472f6ce55789a0ced) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -3,8 +3,11 @@ using System.Data.Entity.Core; using System.IO; using Application.Ringtoets.Storage.Converter; -using Application.Ringtoets.Storage.Properties; +using Application.Ringtoets.Storage.Exceptions; using Core.Common.Base.Data; +using Core.Common.Utils; +using Core.Common.Utils.Builders; +using UtilsResources = Core.Common.Utils.Properties.Resources; namespace Application.Ringtoets.Storage { @@ -21,11 +24,20 @@ /// Path to database file. public StorageSqLite(string databaseFilePath) { + try + { + FileUtils.ValidateFilePath(databaseFilePath); + } + catch (ArgumentException e) + { + throw new InvalidFileException(e.Message, e); + } if (!File.Exists(databaseFilePath)) { - var message = Resources.Error_File_does_not_exist; + var message = new FileReaderErrorMessageBuilder(databaseFilePath).Build(UtilsResources.Error_File_does_not_exist); throw new FileNotFoundException(message); } + connectionString = SqLiteStorageConnection.BuildConnectionString(databaseFilePath); } @@ -46,7 +58,7 @@ { dbContext.Database.Initialize(true); dbContext.Database.Connection.Open(); - dbContext.ProjectEntities.Load(); + dbContext.Versions.Load(); return true; } catch (InvalidOperationException) Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Version.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Version.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Version.cs (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Application.Ringtoets.Storage +{ + using System; + using System.Collections.Generic; + + public partial class Version + { + public long VersionId { get; set; } + public string FromVersion { get; set; } + public string ToVersion { get; set; } + public Nullable Timestamp { get; set; } + } +} Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSQLiteTest.cs =================================================================== diff -u -r3a8bff057967bdb42389382472f6ce55789a0ced -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSQLiteTest.cs (.../StorageSQLiteTest.cs) (revision 3a8bff057967bdb42389382472f6ce55789a0ced) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSQLiteTest.cs (.../StorageSQLiteTest.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -1,7 +1,11 @@ -using System.IO; -using Application.Ringtoets.Storage.Properties; +using System; +using System.IO; +using Application.Ringtoets.Storage.Exceptions; +using Core.Common.Base.Data; using Core.Common.TestUtil; +using Core.Common.Utils.Builders; using NUnit.Framework; +using UtilsResources = Core.Common.Utils.Properties.Resources; namespace Application.Ringtoets.Storage.Test { @@ -28,6 +32,19 @@ [Test] [TestCase(null)] [TestCase("")] + public void Constructor_FileNullOrEmpty_throwsFileNotFoundException(string invalidPath) + { + // Call + TestDelegate test = () => new StorageSqLite(invalidPath); + + // Assert + var exception = Assert.Throws(test); + var expectedMessage = String.Format("Fout bij het lezen van bestand '{0}': {1}", + invalidPath, UtilsResources.Error_Path_must_be_specified); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] [TestCase("NonExistingFile")] public void Constructor_invalidPath_throwsFileNotFoundException(string invalidPath) { @@ -36,7 +53,8 @@ // Assert var exception = Assert.Throws(test); - Assert.AreEqual(Resources.Error_File_does_not_exist, exception.Message); + var expectedMessage = new FileReaderErrorMessageBuilder(invalidPath).Build(UtilsResources.Error_File_does_not_exist); + Assert.AreEqual(expectedMessage, exception.Message); } [Test] @@ -55,6 +73,24 @@ } [Test] + [TestCase("ValidRingtoetsDatabase.rt")] + public void LoadProject_validDatabase_ReturnsProject(string validPath) + { + // Setup + var dbFile = Path.Combine(testDataPath, validPath); + + // Precondition + Assert.IsTrue(File.Exists(dbFile), "Precondition: file must exist."); + + // Call + var storage = new StorageSqLite(dbFile); + Assert.True(storage.TestConnection(), "Precondition: file must be a valid Ringtoets database."); + + var loadedProject = storage.LoadProject(); + Assert.IsInstanceOf(loadedProject); + } + + [Test] [TestCase("empty.rt")] public void TestConnection_invalidConnection_ReturnsFalse(string invalidPath) { Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/test-data/DatabaseFiles/ValidRingtoetsDatabase.rt =================================================================== diff -u -r3a8bff057967bdb42389382472f6ce55789a0ced -r654d3a712eedbdeea718dc0448c5544f09e053cd Binary files differ Index: Core/Common/src/Core.Common.Utils/Builders/FileReaderErrorMessageBuilder.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Utils/Builders/FileReaderErrorMessageBuilder.cs (revision 0) +++ Core/Common/src/Core.Common.Utils/Builders/FileReaderErrorMessageBuilder.cs (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -0,0 +1,59 @@ +namespace Core.Common.Utils.Builders +{ + /// + /// Class to help create consistent file reader error messages. + /// + public class FileReaderErrorMessageBuilder + { + private readonly string filePath; + private string location; + private string subject; + + /// + /// Initializes a new instance of the class. + /// + /// The file path to the file where the error occurred. + public FileReaderErrorMessageBuilder(string filePath) + { + this.filePath = filePath; + } + + /// + /// Builds the specified error message. + /// + /// The message about the error that has occurred. + /// The full error message. + public string Build(string errorMessage) + { + return string.Format("Fout bij het lezen van bestand '{0}'{1}{2}: {3}", + filePath, + location ?? string.Empty, + subject ?? string.Empty, + errorMessage); + } + + /// + /// Adds file location information to the error message. + /// + /// The location description. + /// The builder being configured. + /// line 7 + public FileReaderErrorMessageBuilder WithLocation(string locationDescription) + { + location = " " + locationDescription; + return this; + } + + /// + /// Adds the subject where the error occurred to the error message. + /// + /// The subject description. + /// The builder being configured. + /// soil profile 'blabla' + public FileReaderErrorMessageBuilder WithSubject(string subjectDescription) + { + subject = string.Format(" ({0})", subjectDescription); + return this; + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Utils/Core.Common.Utils.csproj =================================================================== diff -u -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Core/Common/src/Core.Common.Utils/Core.Common.Utils.csproj (.../Core.Common.Utils.csproj) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) +++ Core/Common/src/Core.Common.Utils/Core.Common.Utils.csproj (.../Core.Common.Utils.csproj) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -91,6 +91,7 @@ + @@ -100,10 +101,11 @@ - + + True True - Resource.resx + Resources.resx @@ -153,10 +155,9 @@ - - ResXFileCodeGenerator - Resource.Designer.cs - Designer + + PublicResXFileCodeGenerator + Resources.Designer.cs Index: Core/Common/src/Core.Common.Utils/FileUtils.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Utils/FileUtils.cs (revision 0) +++ Core/Common/src/Core.Common.Utils/FileUtils.cs (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -0,0 +1,45 @@ +using System; +using System.IO; +using Core.Common.Utils.Properties; +using Core.Common.Utils.Builders; + +namespace Core.Common.Utils +{ + /// + /// Class with reusable File related utility methods. + /// + public static class FileUtils + { + /// + /// Validates the file path. + /// + /// The file path to be validated. + /// is invalid. + public static void ValidateFilePath(string path) + { + if (String.IsNullOrWhiteSpace(path)) + { + var message = new FileReaderErrorMessageBuilder(path).Build(Resources.Error_Path_must_be_specified); + throw new ArgumentException(message); + } + + string name; + try + { + name = Path.GetFileName(path); + } + catch (ArgumentException e) + { + var message = new FileReaderErrorMessageBuilder(path) + .Build(String.Format(Resources.Error_Path_cannot_contain_Characters_0_, + String.Join(", ", Path.GetInvalidFileNameChars()))); + throw new ArgumentException(message, e); + } + if (String.Empty == name) + { + var message = new FileReaderErrorMessageBuilder(path).Build(Resources.Error_Path_must_not_point_to_folder); + throw new ArgumentException(message); + } + } + } +} \ No newline at end of file Fisheye: Tag 654d3a712eedbdeea718dc0448c5544f09e053cd refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Utils/Properties/Resource.Designer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 654d3a712eedbdeea718dc0448c5544f09e053cd refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Utils/Properties/Resource.resx'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/src/Core.Common.Utils/Properties/Resources.Designer.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Utils/Properties/Resources.Designer.cs (revision 0) +++ Core/Common/src/Core.Common.Utils/Properties/Resources.Designer.cs (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -0,0 +1,254 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Core.Common.Utils.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Core.Common.Utils.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Kon 'Assembly' informatie niet lezen voor {0} : {1}. + /// + public static string AssemblyUtils_LoadAllAssembliesFromDirectory_Could_not_read_assembly_information_for_0_1_ { + get { + return ResourceManager.GetString("AssemblyUtils_LoadAllAssembliesFromDirectory_Could_not_read_assembly_information_" + + "for_0_1_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Parameter 'GroupSize' moet groter zijn dan 0.. + /// + public static string EnumerableExtensions_SplitInGroups_GroupSize_must_be_greater_than_0 { + get { + return ResourceManager.GetString("EnumerableExtensions_SplitInGroups_GroupSize_must_be_greater_than_0", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Het bestandspad verwijst naar een map die niet bestaat.. + /// + public static string Error_Directory_missing { + get { + return ResourceManager.GetString("Error_Directory_missing", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Het bestand bestaat niet.. + /// + public static string Error_File_does_not_exist { + get { + return ResourceManager.GetString("Error_File_does_not_exist", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Het bestand is leeg.. + /// + public static string Error_File_empty { + get { + return ResourceManager.GetString("Error_File_empty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Er is een onverwachte fout opgetreden tijdens het inlezen van het bestand: {0}. + /// + public static string Error_General_IO_ErrorMessage_0_ { + get { + return ResourceManager.GetString("Error_General_IO_ErrorMessage_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Regel bevat te veel tekst om in het RAM geheugen opgeslagen te worden.. + /// + public static string Error_Line_too_big_for_RAM { + get { + return ResourceManager.GetString("Error_Line_too_big_for_RAM", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bestandspad mag niet de volgende tekens bevatten: {0}. + /// + public static string Error_Path_cannot_contain_Characters_0_ { + get { + return ResourceManager.GetString("Error_Path_cannot_contain_Characters_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bestandspad mag niet leeg of ongedefinieerd zijn.. + /// + public static string Error_Path_must_be_specified { + get { + return ResourceManager.GetString("Error_Path_must_be_specified", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bestandspad mag niet naar een map verwijzen.. + /// + public static string Error_Path_must_not_point_to_folder { + get { + return ResourceManager.GetString("Error_Path_must_not_point_to_folder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Kopiëren van {0}\{1}. + /// + public static string FileUtils_CopyAll_Copying_0_1_ { + get { + return ResourceManager.GetString("FileUtils_CopyAll_Copying_0_1_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to afgebroken. + /// + public static string InvokeRequiredAttribute_LogInvokeError_aborted { + get { + return ResourceManager.GetString("InvokeRequiredAttribute_LogInvokeError_aborted", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to wordt overgeslagen. + /// + public static string InvokeRequiredAttribute_LogInvokeError_skipping { + get { + return ResourceManager.GetString("InvokeRequiredAttribute_LogInvokeError_skipping", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Thread synchronisatiefout (aanroep {1}): {0}. + /// + public static string InvokeRequiredAttribute_LogInvokeError_Thread_synchronization_error_call_1_0_ { + get { + return ResourceManager.GetString("InvokeRequiredAttribute_LogInvokeError_Thread_synchronization_error_call_1_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Geprobeerd het kenmerk in de beschikbare spatiale data te vervangen, maar kon kenmerk niet vinden in de oorspronkelijke context: {0}.. + /// + public static string ObjectHelper_CouldNotFindFeatureInOriginalContext { + get { + return ResourceManager.GetString("ObjectHelper_CouldNotFindFeatureInOriginalContext", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Kan methode {0}.TryParse(string, out {0}) niet vinden.. + /// + public static string ParseHelper_ParseHelper_Cannot_find_method_0_TryParse_string_out_0_ { + get { + return ResourceManager.GetString("ParseHelper_ParseHelper_Cannot_find_method_0_TryParse_string_out_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Kritieke fout opgetreden.. + /// + public static string TypeUtils_CallMethod_Exception_occured { + get { + return ResourceManager.GetString("TypeUtils_CallMethod_Exception_occured", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Geen 'default constructor' gevonden voor type {0}.. + /// + public static string TypeUtils_CreateInstance_No_default_constructor_available_for_type_0_ { + get { + return ResourceManager.GetString("TypeUtils_CreateInstance_No_default_constructor_available_for_type_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to '{0}' is geen geldige expressie voor deze methode.. + /// + public static string TypeUtils_GetMemberName_0_is_not_a_valid_expression_for_this_method { + get { + return ResourceManager.GetString("TypeUtils_GetMemberName_0_is_not_a_valid_expression_for_this_method", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Parameter 'member' is geen geldige expressie voor deze methode.. + /// + public static string TypeUtils_GetMemberNameFromMemberExpression_member_not_a_valid_expression_for_this_method { + get { + return ResourceManager.GetString("TypeUtils_GetMemberNameFromMemberExpression_member_not_a_valid_expression_for_thi" + + "s_method", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0}, ernst: {1} ({2} fout(en), {3} waarschuwing(en), {4} info).. + /// + public static string ValidationReport_ToString_0_severity_1_2_error_s_3_warnings_4_info { + get { + return ResourceManager.GetString("ValidationReport_ToString_0_severity_1_2_error_s_3_warnings_4_info", resourceCulture); + } + } + } +} Index: Core/Common/src/Core.Common.Utils/Properties/Resources.resx =================================================================== diff -u --- Core/Common/src/Core.Common.Utils/Properties/Resources.resx (revision 0) +++ Core/Common/src/Core.Common.Utils/Properties/Resources.resx (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Kon 'Assembly' informatie niet lezen voor {0} : {1} + + + Parameter 'GroupSize' moet groter zijn dan 0. + + + Het bestandspad verwijst naar een map die niet bestaat. + + + Het bestand bestaat niet. + + + Het bestand is leeg. + + + Er is een onverwachte fout opgetreden tijdens het inlezen van het bestand: {0} + + + Regel bevat te veel tekst om in het RAM geheugen opgeslagen te worden. + + + Bestandspad mag niet de volgende tekens bevatten: {0} + + + Bestandspad mag niet leeg of ongedefinieerd zijn. + + + Bestandspad mag niet naar een map verwijzen. + + + Kopiëren van {0}\{1} + + + afgebroken + + + wordt overgeslagen + + + Thread synchronisatiefout (aanroep {1}): {0} + + + Geprobeerd het kenmerk in de beschikbare spatiale data te vervangen, maar kon kenmerk niet vinden in de oorspronkelijke context: {0}. + + + Kan methode {0}.TryParse(string, out {0}) niet vinden. + + + Kritieke fout opgetreden. + + + Geen 'default constructor' gevonden voor type {0}. + + + Parameter 'member' is geen geldige expressie voor deze methode. + + + '{0}' is geen geldige expressie voor deze methode. + + + {0}, ernst: {1} ({2} fout(en), {3} waarschuwing(en), {4} info). + + \ No newline at end of file Index: Core/Common/src/Core.Common.Utils/Reflection/AssemblyUtils.cs =================================================================== diff -u -r942c15559d170726bdfe0dada2077be40a010b87 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Core/Common/src/Core.Common.Utils/Reflection/AssemblyUtils.cs (.../AssemblyUtils.cs) (revision 942c15559d170726bdfe0dada2077be40a010b87) +++ Core/Common/src/Core.Common.Utils/Reflection/AssemblyUtils.cs (.../AssemblyUtils.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -264,7 +264,7 @@ } catch (Exception exception) { - log.ErrorFormat(Resource.AssemblyUtils_LoadAllAssembliesFromDirectory_Could_not_read_assembly_information_for_0_1_, assemblyName, exception.Message); + log.ErrorFormat(Resources.AssemblyUtils_LoadAllAssembliesFromDirectory_Could_not_read_assembly_information_for_0_1_, assemblyName, exception.Message); continue; } Index: Core/Common/src/Core.Common.Utils/Reflection/TypeUtils.cs =================================================================== diff -u -r6c693d509fdef4935fdede8b547f1f815f70ebb2 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Core/Common/src/Core.Common.Utils/Reflection/TypeUtils.cs (.../TypeUtils.cs) (revision 6c693d509fdef4935fdede8b547f1f815f70ebb2) +++ Core/Common/src/Core.Common.Utils/Reflection/TypeUtils.cs (.../TypeUtils.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -223,7 +223,7 @@ return GetMemberNameFromMemberExpression(unary.Operand as MemberExpression); } - var message = string.Format(Resource.TypeUtils_GetMemberName_0_is_not_a_valid_expression_for_this_method, e); + var message = string.Format(Resources.TypeUtils_GetMemberName_0_is_not_a_valid_expression_for_this_method, e); throw new ArgumentException(message); } @@ -433,7 +433,7 @@ if (defaultConstructor == null) { - throw new NotImplementedException(string.Format(Resource.TypeUtils_CreateInstance_No_default_constructor_available_for_type_0_, type)); + throw new NotImplementedException(string.Format(Resources.TypeUtils_CreateInstance_No_default_constructor_available_for_type_0_, type)); } return (T) Activator.CreateInstance(type, true); @@ -486,7 +486,7 @@ // re-throw original exception if (e.InnerException != null) { - log.Error(Resource.TypeUtils_CallMethod_Exception_occured, e); // log outer exception + log.Error(Resources.TypeUtils_CallMethod_Exception_occured, e); // log outer exception throw e.InnerException; } @@ -515,7 +515,7 @@ { return member.Member.Name; } - throw new ArgumentException(Resource.TypeUtils_GetMemberNameFromMemberExpression_member_not_a_valid_expression_for_this_method); + throw new ArgumentException(Resources.TypeUtils_GetMemberNameFromMemberExpression_member_not_a_valid_expression_for_this_method); } private static FieldInfo GetFieldInfo(Type type, string fieldName) Index: Core/Common/src/Core.Common.Utils/Validation/ValidationReport.cs =================================================================== diff -u -r622c20f6fc0b693b67a3e57b2ece939823002c62 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Core/Common/src/Core.Common.Utils/Validation/ValidationReport.cs (.../ValidationReport.cs) (revision 622c20f6fc0b693b67a3e57b2ece939823002c62) +++ Core/Common/src/Core.Common.Utils/Validation/ValidationReport.cs (.../ValidationReport.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -161,7 +161,7 @@ public override string ToString() { - return string.Format(Resource.ValidationReport_ToString_0_severity_1_2_error_s_3_warnings_4_info, + return string.Format(Resources.ValidationReport_ToString_0_severity_1_2_error_s_3_warnings_4_info, Category, Severity, ErrorCount, WarningCount, InfoCount); } Index: Core/Common/test/Core.Common.TestUtil/TestDataPath.cs =================================================================== diff -u -r3a8bff057967bdb42389382472f6ce55789a0ced -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Core/Common/test/Core.Common.TestUtil/TestDataPath.cs (.../TestDataPath.cs) (revision 3a8bff057967bdb42389382472f6ce55789a0ced) +++ Core/Common/test/Core.Common.TestUtil/TestDataPath.cs (.../TestDataPath.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -21,19 +21,14 @@ { public static readonly TestDataPath Storage = System.IO.Path.Combine("Application", "Ringtoets", "test", "Application.Ringtoets.Storage.Test"); } - - public static readonly TestDataPath CorePluginsSharpMapGisTests = - @"Core/Plugins/test/Core.Plugins.SharpMapGis.Test/"; } - public static class Common + public static class Core { - public static readonly TestDataPath CoreCommonUtilsTests = - System.IO.Path.Combine("Core", "Common", "test", "Core.Common.Utils.Test"); - - public static class Base + public static class Common { - public static readonly TestDataPath CoreCommonBaseTests = @"Core/Common/test/Core.Common.Base.Test"; + public static readonly TestDataPath Base = System.IO.Path.Combine("Core", "Common", "test", "Core.Common.Base.Test"); + public static readonly TestDataPath Utils = System.IO.Path.Combine("Core", "Common", "test", "Core.Common.Utils.Test"); } } @@ -43,9 +38,6 @@ { public static readonly TestDataPath IO = System.IO.Path.Combine("Ringtoets", "Piping", "test", "Ringtoets.Piping.IO.Test"); } - - public static readonly TestDataPath CorePluginsSharpMapGisTests = - @"Core/Plugins/test/Core.Plugins.SharpMapGis.Test/"; } } } \ No newline at end of file Index: Core/Common/test/Core.Common.TestUtil/TestHelper.cs =================================================================== diff -u -r632b9c8cd36e7663a17e53320d3bfedb873889e0 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Core/Common/test/Core.Common.TestUtil/TestHelper.cs (.../TestHelper.cs) (revision 632b9c8cd36e7663a17e53320d3bfedb873889e0) +++ Core/Common/test/Core.Common.TestUtil/TestHelper.cs (.../TestHelper.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -7,11 +7,9 @@ using System.Linq; using System.Reflection; using System.Windows.Forms; - using log4net.Appender; using log4net.Config; using log4net.Core; - using NUnit.Framework; namespace Core.Common.TestUtil @@ -196,12 +194,12 @@ } var userMessage = String.IsNullOrEmpty(message) ? "" : message + ". "; - if ( ! rank.Equals(1.0f)) + if (!rank.Equals(1.0f)) { - Assert.IsTrue(rank * actualMillisecond < maxMilliseconds, userMessage + "Maximum of {0} milliseconds exceeded. Actual was {1}, machine performance weighted actual was {2}", - maxMilliseconds, actualMillisecond, actualMillisecond * rank); + Assert.IsTrue(rank*actualMillisecond < maxMilliseconds, userMessage + "Maximum of {0} milliseconds exceeded. Actual was {1}, machine performance weighted actual was {2}", + maxMilliseconds, actualMillisecond, actualMillisecond*rank); Console.WriteLine(userMessage + String.Format("Test took {1} milliseconds (machine performance weighted {2}). Maximum was {0}", - maxMilliseconds, actualMillisecond, actualMillisecond * rank)); + maxMilliseconds, actualMillisecond, actualMillisecond*rank)); } else { @@ -243,7 +241,7 @@ AssertExpectedMessagesInRenderedMessages(messages, renderedMessages); if (expectedLogMessageCount != null) { - Assert.AreEqual((int)expectedLogMessageCount, renderedMessages.Count()); + Assert.AreEqual((int) expectedLogMessageCount, renderedMessages.Count()); } } @@ -331,6 +329,30 @@ AssertContextMenuStripContainsItem(menu.DropDownItems, position, text, toolTip, icon, enabled); } + /// + /// Asserts that the exception is of type and that the custom part of + /// is equal to . + /// + /// The type of the expected exception. + /// The test to execute and should throw exception of type . + /// The expected custom part of the exception message. + public static void AssertThrowsArgumentExceptionAndTestMessage(TestDelegate test, string expectedCustomMessage) where T : ArgumentException + { + var exception = Assert.Throws(test); + var message = exception.Message; + if (exception.ParamName != null) + { + var customMessageParts = message.Split(new[] + { + Environment.NewLine + }, StringSplitOptions.None).ToList(); + customMessageParts.RemoveAt(customMessageParts.Count - 1); + + message = String.Join(Environment.NewLine, customMessageParts.ToArray()); + } + Assert.AreEqual(expectedCustomMessage, message); + } + private static void AssertContextMenuStripContainsItem(ToolStripItemCollection items, int position, string text, string toolTip, Image icon, bool enabled = true) { Assert.Less(position, items.Count); @@ -368,30 +390,6 @@ } } - /// - /// Asserts that the exception is of type and that the custom part of - /// is equal to . - /// - /// The type of the expected exception. - /// The test to execute and should throw exception of type . - /// The expected custom part of the exception message. - public static void AssertThrowsArgumentExceptionAndTestMessage(TestDelegate test, string expectedCustomMessage) where T : ArgumentException - { - var exception = Assert.Throws(test); - var message = exception.Message; - if (exception.ParamName != null) - { - var customMessageParts = message.Split(new[] - { - Environment.NewLine - }, StringSplitOptions.None).ToList(); - customMessageParts.RemoveAt(customMessageParts.Count - 1); - - message = String.Join(Environment.NewLine, customMessageParts.ToArray()); - } - Assert.AreEqual(expectedCustomMessage, message); - } - private static string GetCurrentTestClassMethodName() { var stackTrace = new StackTrace(false); @@ -498,15 +496,15 @@ private static Color[] GetImageAsColorArray(Image image) { // Convert image to ARGB bitmap using 8bits/channel: - var bitmap = new Bitmap(image).Clone(new Rectangle(0,0, image.Size.Width, image.Size.Height), PixelFormat.Format32bppArgb); + var bitmap = new Bitmap(image).Clone(new Rectangle(0, 0, image.Size.Width, image.Size.Height), PixelFormat.Format32bppArgb); var index = 0; - var imageColors = new Color[image.Size.Width * image.Size.Height]; + var imageColors = new Color[image.Size.Width*image.Size.Height]; for (int i = 0; i < bitmap.Height; i++) { for (int j = 0; j < bitmap.Width; j++) { - imageColors[index] = bitmap.GetPixel(i,j); + imageColors[index] = bitmap.GetPixel(i, j); } } return imageColors; Index: Core/Common/test/Core.Common.Utils.Test/Builders/FileReaderErrorMessageBuilderTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Utils.Test/Builders/FileReaderErrorMessageBuilderTest.cs (revision 0) +++ Core/Common/test/Core.Common.Utils.Test/Builders/FileReaderErrorMessageBuilderTest.cs (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -0,0 +1,77 @@ +using Core.Common.Utils.Builders; +using NUnit.Framework; + +namespace Core.Common.Utils.Test.Builders +{ + [TestFixture] + public class FileReaderErrorMessageBuilderTest + { + [Test] + public void Build_BasedOnPathAndMessage_ReturnBuiltErrorMessage() + { + // Setup + const string filePath = ""; + const string errorMessage = "test test 1,2,3"; + + // Call + var message = new FileReaderErrorMessageBuilder(filePath).Build(errorMessage); + + // Assert + var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': {1}", + filePath, errorMessage); + Assert.AreEqual(expectedMessage, message); + } + + [Test] + public void Build_BasedOnPathAndMessageWithLocation_ReturnBuiltErrorMessage() + { + // Setup + const string filePath = ""; + const string errorMessage = "test test 1,2,3"; + const string location = ""; + + // Call + var message = new FileReaderErrorMessageBuilder(filePath).WithLocation(location).Build(errorMessage); + + // Assert + var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}' {1}: {2}", + filePath, location, errorMessage); + Assert.AreEqual(expectedMessage, message); + } + + [Test] + public void Build_BasedOnPathAndMessageWithSubject_ReturnBuiltErrorMessage() + { + // Setup + const string filePath = ""; + const string errorMessage = "test test 1,2,3"; + const string subject = ""; + + // Call + var message = new FileReaderErrorMessageBuilder(filePath).WithSubject(subject).Build(errorMessage); + + // Assert + var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}' ({1}): {2}", + filePath, subject, errorMessage); + Assert.AreEqual(expectedMessage, message); + } + + [Test] + public void Build_BasedOnPathAndMessageWithSubjectAndLocation_ReturnBuiltErrorMessage() + { + // Setup + const string filePath = ""; + const string errorMessage = "test test 1,2,3"; + const string subject = ""; + const string location = ""; + + // Call + var message = new FileReaderErrorMessageBuilder(filePath).WithSubject(subject).WithLocation(location).Build(errorMessage); + + // Assert + var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}' {1} ({2}): {3}", + filePath, location, subject, errorMessage); + Assert.AreEqual(expectedMessage, message); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Utils.Test/Core.Common.Utils.Test.csproj =================================================================== diff -u -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Core/Common/test/Core.Common.Utils.Test/Core.Common.Utils.Test.csproj (.../Core.Common.Utils.Test.csproj) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) +++ Core/Common/test/Core.Common.Utils.Test/Core.Common.Utils.Test.csproj (.../Core.Common.Utils.Test.csproj) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -86,13 +86,15 @@ + + Index: Core/Common/test/Core.Common.Utils.Test/FileUtilsTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Utils.Test/FileUtilsTest.cs (revision 0) +++ Core/Common/test/Core.Common.Utils.Test/FileUtilsTest.cs (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -0,0 +1,72 @@ +using System; +using System.IO; +using Core.Common.TestUtil; +using NUnit.Framework; + +namespace Core.Common.Utils.Test +{ + [TestFixture] + public class FileUtilsTest + { + [Test] + public void ValidateFilePath_ValidPath_DoesNotThrowAnyExceptions() + { + // Setup + var path = TestHelper.GetTestDataPath(TestDataPath.Core.Common.Utils, "validFile.txt"); + + // Call + TestDelegate call = () => FileUtils.ValidateFilePath(path); + + // Assert + Assert.DoesNotThrow(call); + } + + [Test] + [TestCase(null)] + [TestCase("")] + [TestCase(" ")] + public void ValidateFilePath_InvalidEmptyPath_ThrowsArgumentException(string invalidPath) + { + // Call + TestDelegate call = () => FileUtils.ValidateFilePath(invalidPath); + + // Assert + var exception = Assert.Throws(call); + var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': Bestandspad mag niet leeg of ongedefinieerd zijn.", invalidPath); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void ValidateFilePath_PathContainingInvalidFileCharacters_ThrowsArgumentException() + { + // Setup + var path = TestHelper.GetTestDataPath(TestDataPath.Core.Common.Utils, "validFile.txt"); + var invalidFileNameChars = Path.GetInvalidFileNameChars(); + var invalidPath = path.Replace('d', invalidFileNameChars[0]); + + // Call + TestDelegate call = () => FileUtils.ValidateFilePath(invalidPath); + + // Assert + var exception = Assert.Throws(call); + var expectedMessage = String.Format("Fout bij het lezen van bestand '{0}': Bestandspad mag niet de volgende tekens bevatten: {1}", + invalidPath, string.Join(", ", invalidFileNameChars)); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void ValidateFilePath_PathIsActuallyFolder_ThrowsArgumentException() + { + // Setup + var folderPath = TestHelper.GetTestDataPath(TestDataPath.Core.Common.Utils) + Path.DirectorySeparatorChar; + + // Call + TestDelegate call = () => FileUtils.ValidateFilePath(folderPath); + + // Assert + var exception = Assert.Throws(call); + var expectedMessage = String.Format("Fout bij het lezen van bestand '{0}': Bestandspad mag niet naar een map verwijzen.", folderPath); + Assert.AreEqual(expectedMessage, exception.Message); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Utils.Test/Properties/Resources.Designer.cs =================================================================== diff -u -r632b9c8cd36e7663a17e53320d3bfedb873889e0 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Core/Common/test/Core.Common.Utils.Test/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 632b9c8cd36e7663a17e53320d3bfedb873889e0) +++ Core/Common/test/Core.Common.Utils.Test/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18444 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. Index: Core/Common/test/Core.Common.Utils.Test/TestHelperTests.cs =================================================================== diff -u -r9c29a906e8ee9c993982d4dc4a3bf2e148af40a0 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Core/Common/test/Core.Common.Utils.Test/TestHelperTests.cs (.../TestHelperTests.cs) (revision 9c29a906e8ee9c993982d4dc4a3bf2e148af40a0) +++ Core/Common/test/Core.Common.Utils.Test/TestHelperTests.cs (.../TestHelperTests.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -31,15 +31,19 @@ } [Test] - public void TestPredefinedTestPath() + public void GetTestDataPath_Always_VerifiedTestPaths() { - // common - var path = TestHelper.GetTestDataPath(TestDataPath.Common.Base.CoreCommonBaseTests); + // Core Common Base + var path = TestHelper.GetTestDataPath(TestDataPath.Core.Common.Base); Assert.IsTrue(Directory.Exists(path)); - // Ringtoets - path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.CorePluginsSharpMapGisTests); + // Core Common Utils + path = TestHelper.GetTestDataPath(TestDataPath.Core.Common.Utils); Assert.IsTrue(Directory.Exists(path)); + + // Ringtoets Piping IO + path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO); + Assert.IsTrue(Directory.Exists(path)); } [Test] @@ -56,36 +60,6 @@ TestHelper.AssertLogMessageIsGenerated(() => log.Error("hello"), "hello"); } - private static void DeleteIfExists(string path) - { - if (!File.Exists(path) & !Directory.Exists(path)) - { - return; - } - - var attributes = File.GetAttributes(path); - - // if file is readonly - make it non-readonly - if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) - { - File.SetAttributes(path, attributes ^ FileAttributes.ReadOnly); - } - - // now delete everything - if (File.Exists(path)) - { - File.Delete(path); - } - else if (Directory.Exists(path)) - { - foreach (var path2 in Directory.GetDirectories(path).Union(Directory.GetFiles(path))) - { - DeleteIfExists(path2); - } - Directory.Delete(path); - } - } - [Test] public void TestAssertLogMessagesCount() { @@ -102,7 +76,7 @@ // Call TestDelegate call = () => TestHelper.AssertImagesAreEqual(image, image); - + // Assert Assert.DoesNotThrow(call); } @@ -170,10 +144,7 @@ contextMenuStrip.Items.Add(testItem); // Call - TestDelegate call = () => - { - TestHelper.AssertContextMenuStripContainsItem(contextMenuStrip, 0, testItem.Text + "someThing", testItem.ToolTipText, testItem.Image); - }; + TestDelegate call = () => { TestHelper.AssertContextMenuStripContainsItem(contextMenuStrip, 0, testItem.Text + "someThing", testItem.ToolTipText, testItem.Image); }; // Assert Assert.Throws(call); @@ -188,10 +159,7 @@ contextMenuStrip.Items.Add(testItem); // Call - TestDelegate call = () => - { - TestHelper.AssertContextMenuStripContainsItem(contextMenuStrip, 0, testItem.Text, testItem.ToolTipText + "someThing", testItem.Image); - }; + TestDelegate call = () => { TestHelper.AssertContextMenuStripContainsItem(contextMenuStrip, 0, testItem.Text, testItem.ToolTipText + "someThing", testItem.Image); }; // Assert Assert.Throws(call); @@ -206,10 +174,7 @@ contextMenuStrip.Items.Add(testItem); // Call - TestDelegate call = () => - { - TestHelper.AssertContextMenuStripContainsItem(contextMenuStrip, 0, testItem.Text, testItem.ToolTipText, Resources.acorn); - }; + TestDelegate call = () => { TestHelper.AssertContextMenuStripContainsItem(contextMenuStrip, 0, testItem.Text, testItem.ToolTipText, Resources.acorn); }; // Assert Assert.Throws(call); @@ -227,10 +192,7 @@ contextMenuStrip.Items.Add(testItem); // Call - TestDelegate call = () => - { - TestHelper.AssertContextMenuStripContainsItem(contextMenuStrip, 0, testItem.Text, testItem.ToolTipText, testItem.Image, !enabled); - }; + TestDelegate call = () => { TestHelper.AssertContextMenuStripContainsItem(contextMenuStrip, 0, testItem.Text, testItem.ToolTipText, testItem.Image, !enabled); }; // Assert Assert.Throws(call); @@ -277,10 +239,7 @@ dropDownItem.DropDownItems.Add(testItem); // Call - TestDelegate call = () => - { - TestHelper.AssertDropDownItemContainsItem(dropDownItem, 0, testItem.Text + "someThing", testItem.ToolTipText, testItem.Image); - }; + TestDelegate call = () => { TestHelper.AssertDropDownItemContainsItem(dropDownItem, 0, testItem.Text + "someThing", testItem.ToolTipText, testItem.Image); }; // Assert Assert.Throws(call); @@ -295,10 +254,7 @@ dropDownItem.DropDownItems.Add(testItem); // Call - TestDelegate call = () => - { - TestHelper.AssertDropDownItemContainsItem(dropDownItem, 0, testItem.Text, testItem.ToolTipText + "someThing", testItem.Image); - }; + TestDelegate call = () => { TestHelper.AssertDropDownItemContainsItem(dropDownItem, 0, testItem.Text, testItem.ToolTipText + "someThing", testItem.Image); }; // Assert Assert.Throws(call); @@ -313,10 +269,7 @@ dropDownItem.DropDownItems.Add(testItem); // Call - TestDelegate call = () => - { - TestHelper.AssertDropDownItemContainsItem(dropDownItem, 0, testItem.Text, testItem.ToolTipText, Resources.acorn); - }; + TestDelegate call = () => { TestHelper.AssertDropDownItemContainsItem(dropDownItem, 0, testItem.Text, testItem.ToolTipText, Resources.acorn); }; // Assert Assert.Throws(call); @@ -334,10 +287,7 @@ dropDownItem.DropDownItems.Add(testItem); // Call - TestDelegate call = () => - { - TestHelper.AssertDropDownItemContainsItem(dropDownItem, 0, testItem.Text, testItem.ToolTipText, testItem.Image, !enabled); - }; + TestDelegate call = () => { TestHelper.AssertDropDownItemContainsItem(dropDownItem, 0, testItem.Text, testItem.ToolTipText, testItem.Image, !enabled); }; // Assert Assert.Throws(call); @@ -362,10 +312,7 @@ TestDelegate t = () => { }; // Call - TestDelegate call = () => - { - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(t, String.Empty); - }; + TestDelegate call = () => { TestHelper.AssertThrowsArgumentExceptionAndTestMessage(t, String.Empty); }; // Assert Assert.Throws(call); @@ -380,10 +327,7 @@ TestDelegate t = () => { throw new ArgumentException(someMessage); }; // Call - TestDelegate call = () => - { - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(t, differentMessage); - }; + TestDelegate call = () => { TestHelper.AssertThrowsArgumentExceptionAndTestMessage(t, differentMessage); }; // Assert Assert.Throws(call); @@ -402,7 +346,6 @@ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(t, someMessage); } - [Test] [TestCase("param")] [TestCase(null)] @@ -416,6 +359,36 @@ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(t, someMessage); } + private static void DeleteIfExists(string path) + { + if (!File.Exists(path) & !Directory.Exists(path)) + { + return; + } + + var attributes = File.GetAttributes(path); + + // if file is readonly - make it non-readonly + if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) + { + File.SetAttributes(path, attributes ^ FileAttributes.ReadOnly); + } + + // now delete everything + if (File.Exists(path)) + { + File.Delete(path); + } + else if (Directory.Exists(path)) + { + foreach (var path2 in Directory.GetDirectories(path).Union(Directory.GetFiles(path))) + { + DeleteIfExists(path2); + } + Directory.Delete(path); + } + } + private static ToolStripMenuItem CreateContextMenuItem() { return new ToolStripMenuItem Fisheye: Tag 654d3a712eedbdeea718dc0448c5544f09e053cd refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/FileReaderErrorMessageBuilder.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 654d3a712eedbdeea718dc0448c5544f09e053cd refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/FileUtils.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/PipingSurfaceLinesCsvReader.cs =================================================================== diff -u -ref38400fe2872ca260d04a30a80de72492b569ad -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/src/Ringtoets.Piping.IO/PipingSurfaceLinesCsvReader.cs (.../PipingSurfaceLinesCsvReader.cs) (revision ef38400fe2872ca260d04a30a80de72492b569ad) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/PipingSurfaceLinesCsvReader.cs (.../PipingSurfaceLinesCsvReader.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -3,11 +3,12 @@ using System.Globalization; using System.IO; using System.Linq; - +using Core.Common.Utils; +using Core.Common.Utils.Builders; using Ringtoets.Piping.Data; -using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; +using UtilsResources = Core.Common.Utils.Properties.Resources; namespace Ringtoets.Piping.IO { @@ -142,6 +143,15 @@ return null; } + public void Dispose() + { + if (fileReader != null) + { + fileReader.Dispose(); + fileReader = null; + } + } + /// /// Checks if the geometry defining the surface line is valid. /// @@ -159,15 +169,6 @@ } } - public void Dispose() - { - if (fileReader != null) - { - fileReader.Dispose(); - fileReader = null; - } - } - /// /// Tokenizes a string using a separator character up to the first empty field. /// @@ -204,20 +205,20 @@ const int expectedValuesForPoint = 3; var worldCoordinateValues = ParseWorldCoordinateValuesAndHandleParseErrors(tokenizedString, surfaceLineName); - if (worldCoordinateValues.Length % expectedValuesForPoint != 0) + if (worldCoordinateValues.Length%expectedValuesForPoint != 0) { throw CreateLineParseException(lineNumber, surfaceLineName, Resources.PipingSurfaceLinesCsvReader_ReadLine_SurfaceLine_lacks_values_for_coordinate_triplet); } - int coordinateCount = worldCoordinateValues.Length / expectedValuesForPoint; + int coordinateCount = worldCoordinateValues.Length/expectedValuesForPoint; var points = new Point3D[coordinateCount]; for (int i = 0; i < coordinateCount; i++) { points[i] = new Point3D { - X = worldCoordinateValues[i * expectedValuesForPoint], - Y = worldCoordinateValues[i * expectedValuesForPoint + 1], - Z = worldCoordinateValues[i * expectedValuesForPoint + 2] + X = worldCoordinateValues[i*expectedValuesForPoint], + Y = worldCoordinateValues[i*expectedValuesForPoint + 1], + Z = worldCoordinateValues[i*expectedValuesForPoint + 2] }; } return points; @@ -284,17 +285,17 @@ } catch (FileNotFoundException e) { - string message = new FileReaderErrorMessageBuilder(path).Build(Resources.Error_File_does_not_exist); + string message = new FileReaderErrorMessageBuilder(path).Build(UtilsResources.Error_File_does_not_exist); throw new CriticalFileReadException(message, e); } catch (DirectoryNotFoundException e) { - string message = new FileReaderErrorMessageBuilder(path).Build(Resources.Error_Directory_missing); + string message = new FileReaderErrorMessageBuilder(path).Build(UtilsResources.Error_Directory_missing); throw new CriticalFileReadException(message, e); } catch (IOException e) { - var message = new FileReaderErrorMessageBuilder(path).Build(string.Format(Resources.Error_General_IO_ErrorMessage_0_, e.Message)); + var message = new FileReaderErrorMessageBuilder(path).Build(string.Format(UtilsResources.Error_General_IO_ErrorMessage_0_, e.Message)); throw new CriticalFileReadException(message, e); } } @@ -317,7 +318,7 @@ } else { - throw CreateCriticalFileReadException(currentLine, Resources.Error_File_empty); + throw CreateCriticalFileReadException(currentLine, UtilsResources.Error_File_empty); } } @@ -405,11 +406,11 @@ } catch (OutOfMemoryException e) { - throw CreateCriticalFileReadException(currentLine, Resources.Error_File_does_not_exist, e); + throw CreateCriticalFileReadException(currentLine, UtilsResources.Error_File_does_not_exist, e); } catch (IOException e) { - var message = new FileReaderErrorMessageBuilder(filePath).Build(string.Format(Resources.Error_General_IO_ErrorMessage_0_, e.Message)); + var message = new FileReaderErrorMessageBuilder(filePath).Build(string.Format(UtilsResources.Error_General_IO_ErrorMessage_0_, e.Message)); throw new CriticalFileReadException(message, e); } } Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r83b9621346f7f3ca887096468de965815eb609ac -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 83b9621346f7f3ca887096468de965815eb609ac) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34209 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -70,78 +70,6 @@ } /// - /// Looks up a localized string similar to Het bestandspad verwijst naar een map die niet bestaat.. - /// - public static string Error_Directory_missing { - get { - return ResourceManager.GetString("Error_Directory_missing", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Het bestand bestaat niet.. - /// - public static string Error_File_does_not_exist { - get { - return ResourceManager.GetString("Error_File_does_not_exist", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Het bestand is leeg.. - /// - public static string Error_File_empty { - get { - return ResourceManager.GetString("Error_File_empty", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Er is een onverwachte fout opgetreden tijdens het inlezen van het bestand: {0}. - /// - public static string Error_General_IO_ErrorMessage_0_ { - get { - return ResourceManager.GetString("Error_General_IO_ErrorMessage_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Regel bevat te veel tekst om in het RAM geheugen opgeslagen te worden.. - /// - public static string Error_Line_too_big_for_RAM { - get { - return ResourceManager.GetString("Error_Line_too_big_for_RAM", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Bestandspad mag niet de volgende tekens bevatten: {0}. - /// - public static string Error_Path_cannot_contain_Characters_0_ { - get { - return ResourceManager.GetString("Error_Path_cannot_contain_Characters_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Bestandspad mag niet leeg of ongedefinieerd zijn.. - /// - public static string Error_Path_must_be_specified { - get { - return ResourceManager.GetString("Error_Path_must_be_specified", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Bestandspad mag niet naar een map verwijzen.. - /// - public static string Error_Path_must_not_point_to_folder { - get { - return ResourceManager.GetString("Error_Path_must_not_point_to_folder", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Kon geen ondergrond profielen verkrijgen van de database.. /// public static string Error_SoilProfile_read_from_database { Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx =================================================================== diff -u -r83b9621346f7f3ca887096468de965815eb609ac -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision 83b9621346f7f3ca887096468de965815eb609ac) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -120,36 +120,12 @@ Er kan geen 1D-profiel bepaald worden wanneer segmenten in een 2D laag verticaal lopen op de gekozen positie: x = {0}. - - Het bestandspad verwijst naar een map die niet bestaat. - - - Regel bevat te veel tekst om in het RAM geheugen opgeslagen te worden. - - - Het bestand bestaat niet. - - - Het bestand is leeg. - Profielmeting heeft een waarde die niet omgezet kan worden naar een getal. Profielmeting heeft een waarde die te groot of te klein is om ingelezen te worden. - - Er is een onverwachte fout opgetreden tijdens het inlezen van het bestand: {0} - - - Bestandspad mag niet de volgende tekens bevatten: {0} - - - Bestandspad mag niet leeg of ongedefinieerd zijn. - - - Bestandspad mag niet naar een map verwijzen. - Geen geldige X waarde gevonden om intersectie te maken uit 2D profiel '{0}'. Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj =================================================================== diff -u -r443423bba9710843153b9afda01bbee47cd1b298 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 443423bba9710843153b9afda01bbee47cd1b298) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -42,7 +42,6 @@ Properties\GlobalAssembly.cs - @@ -52,7 +51,6 @@ - @@ -69,6 +67,10 @@ + + {f49bd8b2-332a-4c91-a196-8cce0a2c7d98} + Core.Common.Utils + {c90b77da-e421-43cc-b82e-529651bc21ac} Core.Common.Version Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/CriticalProfileProperties.cs =================================================================== diff -u -rd082f5444ccd9571f4fabb4c47f1082fa5ece21e -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/CriticalProfileProperties.cs (.../CriticalProfileProperties.cs) (revision d082f5444ccd9571f4fabb4c47f1082fa5ece21e) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/CriticalProfileProperties.cs (.../CriticalProfileProperties.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -1,6 +1,5 @@ using System; - -using Ringtoets.Piping.IO.Builders; +using Core.Common.Utils.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/IRowBasedDatabaseReader.cs =================================================================== diff -u -rd082f5444ccd9571f4fabb4c47f1082fa5ece21e -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/IRowBasedDatabaseReader.cs (.../IRowBasedDatabaseReader.cs) (revision d082f5444ccd9571f4fabb4c47f1082fa5ece21e) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/IRowBasedDatabaseReader.cs (.../IRowBasedDatabaseReader.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -9,6 +9,11 @@ internal interface IRowBasedDatabaseReader { /// + /// Gets the path of the database being read. + /// + string Path { get; } + + /// /// Moves the reader to the next record in the database. /// void MoveNext(); @@ -31,10 +36,5 @@ /// The value in the column, or null if the value was . /// Thrown when the value in the column could not be casted to type . T? ReadOrNull(string columnName) where T : struct; - - /// - /// Gets the path of the database being read. - /// - string Path { get; } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs =================================================================== diff -u -rd082f5444ccd9571f4fabb4c47f1082fa5ece21e -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision d082f5444ccd9571f4fabb4c47f1082fa5ece21e) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -2,10 +2,12 @@ using System.Data; using System.Data.SQLite; using System.IO; +using Core.Common.Utils; +using Core.Common.Utils.Builders; using Ringtoets.Piping.Data; -using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; +using UtilsResources = Core.Common.Utils.Properties.Resources; namespace Ringtoets.Piping.IO.SoilProfile { @@ -48,7 +50,7 @@ } if (!File.Exists(databaseFilePath)) { - var message = new FileReaderErrorMessageBuilder(databaseFilePath).Build(Resources.Error_File_does_not_exist); + var message = new FileReaderErrorMessageBuilder(databaseFilePath).Build(UtilsResources.Error_File_does_not_exist); throw new CriticalFileReadException(message); } Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs =================================================================== diff -u -rd082f5444ccd9571f4fabb4c47f1082fa5ece21e -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs (.../SoilProfile1DReader.cs) (revision d082f5444ccd9571f4fabb4c47f1082fa5ece21e) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs (.../SoilProfile1DReader.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -1,5 +1,6 @@ using System; using System.Data.SQLite; +using Core.Common.Utils.Builders; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; @@ -76,36 +77,6 @@ return pipingSoilLayer; } - private class RequiredProfileProperties - { - internal readonly double Bottom; - - /// - /// Creates a new instance of , which contains properties - /// that are required to create a complete . If these properties - /// cannot be read, then the reader can proceed to the next profile. - /// - /// The to read the required profile property values from. - /// The profile name used in generating exceptions messages if casting failed. - /// Thrown when the values in the database could not be - /// casted to the expected column types. - internal RequiredProfileProperties(IRowBasedDatabaseReader reader, string profileName) - { - string readColumn = SoilProfileDatabaseColumns.Bottom; - try - { - Bottom = reader.Read(readColumn); - } - catch (InvalidCastException e) - { - var message = new FileReaderErrorMessageBuilder(reader.Path) - .WithSubject(string.Format(Resources.PipingSoilProfileReader_SoilProfileName_0_, profileName)) - .Build(string.Format(Resources.PipingSoilProfileReader_Profile_has_invalid_value_on_Column_0_, readColumn)); - throw new PipingSoilProfileReadException(profileName, message, e); - } - } - } - private class LayerProperties { internal readonly double Top; @@ -151,5 +122,35 @@ } } } + + private class RequiredProfileProperties + { + internal readonly double Bottom; + + /// + /// Creates a new instance of , which contains properties + /// that are required to create a complete . If these properties + /// cannot be read, then the reader can proceed to the next profile. + /// + /// The to read the required profile property values from. + /// The profile name used in generating exceptions messages if casting failed. + /// Thrown when the values in the database could not be + /// casted to the expected column types. + internal RequiredProfileProperties(IRowBasedDatabaseReader reader, string profileName) + { + string readColumn = SoilProfileDatabaseColumns.Bottom; + try + { + Bottom = reader.Read(readColumn); + } + catch (InvalidCastException e) + { + var message = new FileReaderErrorMessageBuilder(reader.Path) + .WithSubject(string.Format(Resources.PipingSoilProfileReader_SoilProfileName_0_, profileName)) + .Build(string.Format(Resources.PipingSoilProfileReader_Profile_has_invalid_value_on_Column_0_, readColumn)); + throw new PipingSoilProfileReadException(profileName, message, e); + } + } + } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs =================================================================== diff -u -rd082f5444ccd9571f4fabb4c47f1082fa5ece21e -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision d082f5444ccd9571f4fabb4c47f1082fa5ece21e) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -1,6 +1,6 @@ using System; using System.Data.SQLite; - +using Core.Common.Utils.Builders; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; Fisheye: Tag 654d3a712eedbdeea718dc0448c5544f09e053cd refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/FileReaderErrorMessageBuilderTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 654d3a712eedbdeea718dc0448c5544f09e053cd refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/FileUtilsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/PipingSurfaceLinesCsvReaderTest.cs =================================================================== diff -u -r7612d0b14bca5e0686b654dc0ffb96fcc0ff0a2b -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/PipingSurfaceLinesCsvReaderTest.cs (.../PipingSurfaceLinesCsvReaderTest.cs) (revision 7612d0b14bca5e0686b654dc0ffb96fcc0ff0a2b) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/PipingSurfaceLinesCsvReaderTest.cs (.../PipingSurfaceLinesCsvReaderTest.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -2,12 +2,11 @@ using System.IO; using System.Linq; using Core.Common.TestUtil; +using Core.Common.Utils.Builders; using NUnit.Framework; - -using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; - using IOResources = Ringtoets.Piping.IO.Properties.Resources; +using UtilsResources = Core.Common.Utils.Properties.Resources; namespace Ringtoets.Piping.IO.Test { @@ -27,7 +26,7 @@ // Assert var exception = Assert.Throws(call); - var expectedMessage = new FileReaderErrorMessageBuilder(path).Build(IOResources.Error_Path_must_be_specified); + var expectedMessage = new FileReaderErrorMessageBuilder(path).Build(UtilsResources.Error_Path_must_be_specified); Assert.AreEqual(expectedMessage, exception.Message); } @@ -46,7 +45,7 @@ // Assert var exception = Assert.Throws(call); - var expectedMessage = new FileReaderErrorMessageBuilder(corruptPath).Build(String.Format(IOResources.Error_Path_cannot_contain_Characters_0_, + var expectedMessage = new FileReaderErrorMessageBuilder(corruptPath).Build(String.Format(UtilsResources.Error_Path_cannot_contain_Characters_0_, String.Join(", ", Path.GetInvalidFileNameChars()))); Assert.AreEqual(expectedMessage, exception.Message); } @@ -59,7 +58,7 @@ // Assert var exception = Assert.Throws(call); - var expectedMessage = new FileReaderErrorMessageBuilder(testDataPath).Build(IOResources.Error_Path_must_not_point_to_folder); + var expectedMessage = new FileReaderErrorMessageBuilder(testDataPath).Build(UtilsResources.Error_Path_must_not_point_to_folder); Assert.AreEqual(expectedMessage, exception.Message); } @@ -125,7 +124,7 @@ // Assert var exception = Assert.Throws(call); - var expectedError = new FileReaderErrorMessageBuilder(path).Build(IOResources.Error_File_does_not_exist); + var expectedError = new FileReaderErrorMessageBuilder(path).Build(UtilsResources.Error_File_does_not_exist); Assert.AreEqual(expectedError, exception.Message); Assert.IsInstanceOf(exception.InnerException); } @@ -147,7 +146,7 @@ // Assert var exception = Assert.Throws(call); - var expectedMessage = new FileReaderErrorMessageBuilder(path).Build(IOResources.Error_Directory_missing); + var expectedMessage = new FileReaderErrorMessageBuilder(path).Build(UtilsResources.Error_Directory_missing); Assert.AreEqual(expectedMessage, exception.Message); Assert.IsInstanceOf(exception.InnerException); } @@ -169,7 +168,7 @@ // Assert var exception = Assert.Throws(call); - var expectedMessage = new FileReaderErrorMessageBuilder(path).WithLocation("op regel 1").Build(IOResources.Error_File_empty); + var expectedMessage = new FileReaderErrorMessageBuilder(path).WithLocation("op regel 1").Build(UtilsResources.Error_File_empty); Assert.AreEqual(expectedMessage, exception.Message); } } @@ -303,7 +302,7 @@ // Assert var exception = Assert.Throws(call); - var expectedMessage = new FileReaderErrorMessageBuilder(path).Build(IOResources.Error_File_does_not_exist); + var expectedMessage = new FileReaderErrorMessageBuilder(path).Build(UtilsResources.Error_File_does_not_exist); Assert.AreEqual(expectedMessage, exception.Message); Assert.IsInstanceOf(exception.InnerException); } @@ -325,7 +324,7 @@ // Assert var exception = Assert.Throws(call); - var expectedMessage = new FileReaderErrorMessageBuilder(path).Build(IOResources.Error_Directory_missing); + var expectedMessage = new FileReaderErrorMessageBuilder(path).Build(UtilsResources.Error_Directory_missing); Assert.AreEqual(expectedMessage, exception.Message); Assert.IsInstanceOf(exception.InnerException); } @@ -347,7 +346,7 @@ // Assert var exception = Assert.Throws(call); - var expectedMessage = new FileReaderErrorMessageBuilder(path).WithLocation("op regel 1").Build(IOResources.Error_File_empty); + var expectedMessage = new FileReaderErrorMessageBuilder(path).WithLocation("op regel 1").Build(UtilsResources.Error_File_empty); Assert.AreEqual(expectedMessage, exception.Message); } } Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj =================================================================== diff -u -r443423bba9710843153b9afda01bbee47cd1b298 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 443423bba9710843153b9afda01bbee47cd1b298) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -60,7 +60,6 @@ - @@ -70,7 +69,6 @@ - @@ -82,6 +80,10 @@ + + {f49bd8b2-332a-4c91-a196-8cce0a2c7d98} + Core.Common.Utils + {d749ee4c-ce50-4c17-bf01-9a953028c126} Core.Common.TestUtil Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs =================================================================== diff -u -rd082f5444ccd9571f4fabb4c47f1082fa5ece21e -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs (.../CriticalProfilePropertiesTest.cs) (revision d082f5444ccd9571f4fabb4c47f1082fa5ece21e) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs (.../CriticalProfilePropertiesTest.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -1,8 +1,7 @@ using System; +using Core.Common.Utils.Builders; using NUnit.Framework; using Rhino.Mocks; - -using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; using Ringtoets.Piping.IO.SoilProfile; Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/PipingSoilProfileReaderTest.cs =================================================================== diff -u -r7612d0b14bca5e0686b654dc0ffb96fcc0ff0a2b -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision 7612d0b14bca5e0686b654dc0ffb96fcc0ff0a2b) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -4,13 +4,14 @@ using System.IO; using System.Linq; using Core.Common.TestUtil; +using Core.Common.Utils.Builders; using NUnit.Framework; using Ringtoets.Piping.Data; -using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; using Ringtoets.Piping.IO.SoilProfile; using Ringtoets.Piping.IO.Test.TestHelpers; +using UtilsResources = Core.Common.Utils.Properties.Resources; namespace Ringtoets.Piping.IO.Test.SoilProfile { @@ -29,7 +30,7 @@ // Assert var exception = Assert.Throws(test); - var expectedMessage = new FileReaderErrorMessageBuilder(testFile).Build(Resources.Error_File_does_not_exist); + var expectedMessage = new FileReaderErrorMessageBuilder(testFile).Build(UtilsResources.Error_File_does_not_exist); Assert.AreEqual(expectedMessage, exception.Message); } @@ -44,7 +45,7 @@ // Assert var exception = Assert.Throws(test); var expectedMessage = String.Format("Fout bij het lezen van bestand '{0}': {1}", - fileName, Resources.Error_Path_must_be_specified); + fileName, UtilsResources.Error_Path_must_be_specified); Assert.AreEqual(expectedMessage, exception.Message); } Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs =================================================================== diff -u -rd082f5444ccd9571f4fabb4c47f1082fa5ece21e -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision d082f5444ccd9571f4fabb4c47f1082fa5ece21e) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -1,9 +1,8 @@ using System; using System.Linq; +using Core.Common.Utils.Builders; using NUnit.Framework; using Rhino.Mocks; - -using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.SoilProfile; Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs =================================================================== diff -u -rd082f5444ccd9571f4fabb4c47f1082fa5ece21e -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision d082f5444ccd9571f4fabb4c47f1082fa5ece21e) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -1,9 +1,8 @@ using System; using System.Linq; +using Core.Common.Utils.Builders; using NUnit.Framework; using Rhino.Mocks; - -using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.SoilProfile; using Ringtoets.Piping.IO.Test.TestHelpers; Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs =================================================================== diff -u -rd6e6eadf4a2521df75b6d371bacbb181a43058a3 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs (.../PipingSoilProfilesImporterTest.cs) (revision d6e6eadf4a2521df75b6d371bacbb181a43058a3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs (.../PipingSoilProfilesImporterTest.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -5,14 +5,11 @@ using Core.Common.Base; using Core.Common.Base.IO; using Core.Common.TestUtil; +using Core.Common.Utils.Builders; using NUnit.Framework; - using Rhino.Mocks; - using Ringtoets.Piping.Data; -using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.Plugin.FileImporter; - using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; using RingtoetsFormsResources = Ringtoets.Common.Forms.Properties.Resources; using ApplicationResources = Ringtoets.Piping.Plugin.Properties.Resources; @@ -37,7 +34,7 @@ { // Prepare var expectedFileFilter = String.Format("{0} {1} (*.soil)|*.soil", - PipingFormsResources.PipingSoilProfilesCollection_DisplayName, ApplicationResources.Soil_file_name); + PipingFormsResources.PipingSoilProfilesCollection_DisplayName, ApplicationResources.Soil_file_name); // Call var importer = new PipingSoilProfilesImporter(); @@ -261,7 +258,7 @@ TestHelper.AssertLogMessageIsGenerated(call, expectedLogMessage, 1); Assert.IsFalse(importResult); CollectionAssert.IsEmpty(observableSoilProfileList, - "No items should be added to collection when import is aborted."); + "No items should be added to collection when import is aborted."); Assert.AreEqual(1, progress); mocks.VerifyAll(); // Expect no calls on 'observer' Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLineCsvImporterTest.cs =================================================================== diff -u -r7612d0b14bca5e0686b654dc0ffb96fcc0ff0a2b -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLineCsvImporterTest.cs (.../PipingSurfaceLineCsvImporterTest.cs) (revision 7612d0b14bca5e0686b654dc0ffb96fcc0ff0a2b) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLineCsvImporterTest.cs (.../PipingSurfaceLineCsvImporterTest.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -5,18 +5,16 @@ using Core.Common.Base; using Core.Common.Base.IO; using Core.Common.TestUtil; +using Core.Common.Utils.Builders; using NUnit.Framework; - using Rhino.Mocks; - using Ringtoets.Piping.Data; -using Ringtoets.Piping.IO.Builders; using Ringtoets.Piping.Plugin.FileImporter; - using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; using PipingIOResources = Ringtoets.Piping.IO.Properties.Resources; using RingtoetsFormsResources = Ringtoets.Common.Forms.Properties.Resources; using ApplicationResources = Ringtoets.Piping.Plugin.Properties.Resources; +using UtilsResources = Core.Common.Utils.Properties.Resources; namespace Ringtoets.Piping.Plugin.Test.FileImporter { @@ -38,8 +36,8 @@ Assert.AreEqual(16, importer.Image.Width); Assert.AreEqual(16, importer.Image.Height); Assert.AreEqual(typeof(ICollection), importer.SupportedItemType); - var expectedFileFilter = String.Format("{0} {1} (*.csv)|*.csv", - PipingFormsResources.PipingSurfaceLinesCollection_DisplayName, ApplicationResources.Csv_file_name); + var expectedFileFilter = String.Format("{0} {1} (*.csv)|*.csv", + PipingFormsResources.PipingSurfaceLinesCollection_DisplayName, ApplicationResources.Csv_file_name); Assert.AreEqual(expectedFileFilter, importer.FileFilter); Assert.IsNull(importer.ProgressChanged); } @@ -68,7 +66,7 @@ { Assert.AreEqual(String.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_Read_PipingSurfaceLines_0_, twovalidsurfacelinesCsv), currentStepName); } - else if (callCount == expectedNumberOfSurfaceLines+1) + else if (callCount == expectedNumberOfSurfaceLines + 1) { Assert.AreEqual(ApplicationResources.PipingSurfaceLinesCsvImporter_Adding_imported_data_to_model, currentStepName); } @@ -184,7 +182,7 @@ // Call Action call = () => importResult = importer.Import(observableSurfaceLinesList, validFilePath); - + // Assert TestHelper.AssertLogMessageIsGenerated(call, ApplicationResources.PipingSurfaceLinesCsvImporter_Import_Import_cancelled, 1); Assert.IsFalse(importResult); @@ -250,14 +248,14 @@ Action call = () => importResult = importer.Import(observableSurfaceLinesList, corruptPath); // Assert - var internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath).Build(String.Format(PipingIOResources.Error_Path_cannot_contain_Characters_0_, - String.Join(", ", Path.GetInvalidFileNameChars()))); + var internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath).Build(String.Format(UtilsResources.Error_Path_cannot_contain_Characters_0_, + String.Join(", ", Path.GetInvalidFileNameChars()))); var expectedLogMessage = string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_CriticalErrorMessage_0_File_Skipped, internalErrorMessage); TestHelper.AssertLogMessageIsGenerated(call, expectedLogMessage, 1); Assert.IsFalse(importResult); CollectionAssert.IsEmpty(observableSurfaceLinesList, - "No items should be added to collection when import is aborted."); + "No items should be added to collection when import is aborted."); mocks.VerifyAll(); // Expect no calls on 'observer' } @@ -282,13 +280,13 @@ Action call = () => importResult = importer.Import(observableSurfaceLinesList, corruptPath); // Assert - var internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath).Build(PipingIOResources.Error_File_does_not_exist); + var internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath).Build(UtilsResources.Error_File_does_not_exist); var expectedLogMessage = string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_CriticalErrorMessage_0_File_Skipped, internalErrorMessage); TestHelper.AssertLogMessageIsGenerated(call, expectedLogMessage, 1); Assert.IsFalse(importResult); CollectionAssert.IsEmpty(observableSurfaceLinesList, - "No items should be added to collection when import is aborted."); + "No items should be added to collection when import is aborted."); mocks.VerifyAll(); // Expect no calls on 'observer' } @@ -315,13 +313,13 @@ // Assert var internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath) .WithLocation("op regel 1") - .Build(PipingIOResources.Error_File_empty); + .Build(UtilsResources.Error_File_empty); var expectedLogMessage = string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_CriticalErrorMessage_0_File_Skipped, internalErrorMessage); TestHelper.AssertLogMessageIsGenerated(call, expectedLogMessage, 1); Assert.IsFalse(importResult); CollectionAssert.IsEmpty(observableSurfaceLinesList, - "No items should be added to collection when import is aborted."); + "No items should be added to collection when import is aborted."); mocks.VerifyAll(); // Expect no calls on 'observer' } @@ -354,7 +352,7 @@ TestHelper.AssertLogMessageIsGenerated(call, expectedLogMessage, 1); Assert.IsFalse(importResult); CollectionAssert.IsEmpty(observableSurfaceLinesList, - "No items should be added to collection when import is aborted."); + "No items should be added to collection when import is aborted."); mocks.VerifyAll(); // Expect no calls on 'observer' } @@ -388,7 +386,7 @@ Action call = () => importResult = importer.Import(observableSurfaceLinesList, copyTargetPath); // Assert - var internalErrorMessage = new FileReaderErrorMessageBuilder(copyTargetPath).Build(PipingIOResources.Error_File_does_not_exist); + var internalErrorMessage = new FileReaderErrorMessageBuilder(copyTargetPath).Build(UtilsResources.Error_File_does_not_exist); var expectedLogMessage = string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_CriticalErrorMessage_0_File_Skipped, internalErrorMessage); TestHelper.AssertLogMessageIsGenerated(call, expectedLogMessage, 1); @@ -420,10 +418,7 @@ var importer = new PipingSurfaceLinesCsvImporter(); int progressCallCount = 0; - importer.ProgressChanged += (name, step, steps) => - { - progressCallCount++; - }; + importer.ProgressChanged += (name, step, steps) => { progressCallCount++; }; var observableSurfaceLinesList = new ObservableList(); observableSurfaceLinesList.Attach(observer); @@ -444,12 +439,12 @@ Assert.IsTrue(importResult); Assert.AreEqual(2, observableSurfaceLinesList.Count, - "Ensure only the two valid surfacelines have been imported."); + "Ensure only the two valid surfacelines have been imported."); Assert.AreEqual(1, observableSurfaceLinesList.Count(sl => sl.Name == "Rotterdam1")); Assert.AreEqual(1, observableSurfaceLinesList.Count(sl => sl.Name == "ArtifcialLocal")); Assert.AreEqual(5, progressCallCount, - "Expect 1 call for each surfaceline (3 in total) +1 for 0/N progress, and 1 for putting data in model."); + "Expect 1 call for each surfaceline (3 in total) +1 for 0/N progress, and 1 for putting data in model."); mocks.VerifyAll(); } Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj =================================================================== diff -u -ra5cef96df6e2e617d51e71210cb190ebce097533 -r654d3a712eedbdeea718dc0448c5544f09e053cd --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision a5cef96df6e2e617d51e71210cb190ebce097533) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) @@ -88,6 +88,10 @@ {30e4c2ae-719e-4d70-9fa9-668a9767fbfa} Core.Common.Gui + + {f49bd8b2-332a-4c91-a196-8cce0a2c7d98} + Core.Common.Utils + {d749ee4c-ce50-4c17-bf01-9a953028c126} Core.Common.TestUtil