Index: src/Plugins/Wti/Wti.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r85de34918096850be7844fe93a73336cd7c29d3e -ra4e086ea5fbb916dd649712efd1fe6a195efc8b3 --- src/Plugins/Wti/Wti.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 85de34918096850be7844fe93a73336cd7c29d3e) +++ src/Plugins/Wti/Wti.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a4e086ea5fbb916dd649712efd1fe6a195efc8b3) @@ -712,6 +712,16 @@ } /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap PipingSoilProfileIcon { + get { + object obj = ResourceManager.GetObject("PipingSoilProfileIcon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// /// Looks up a localized string similar to Ondergrondprofielen. /// public static string PipingSoilProfilesCollectionName { Index: src/Plugins/Wti/Wti.Forms/Properties/Resources.resx =================================================================== diff -u -r85de34918096850be7844fe93a73336cd7c29d3e -ra4e086ea5fbb916dd649712efd1fe6a195efc8b3 --- src/Plugins/Wti/Wti.Forms/Properties/Resources.resx (.../Resources.resx) (revision 85de34918096850be7844fe93a73336cd7c29d3e) +++ src/Plugins/Wti/Wti.Forms/Properties/Resources.resx (.../Resources.resx) (revision a4e086ea5fbb916dd649712efd1fe6a195efc8b3) @@ -361,4 +361,7 @@ Importeer nieuwe ondergrondprofielen van een *.soil bestand. + + ..\Resources\chart_curve.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file Index: src/Plugins/Wti/Wti.Forms/Resources/chart_curve.png =================================================================== diff -u Binary files differ Index: src/Plugins/Wti/Wti.Forms/Wti.Forms.csproj =================================================================== diff -u -r4959b3b9b84eec4cb80ec43c037579d9177b3d02 -ra4e086ea5fbb916dd649712efd1fe6a195efc8b3 --- src/Plugins/Wti/Wti.Forms/Wti.Forms.csproj (.../Wti.Forms.csproj) (revision 4959b3b9b84eec4cb80ec43c037579d9177b3d02) +++ src/Plugins/Wti/Wti.Forms/Wti.Forms.csproj (.../Wti.Forms.csproj) (revision a4e086ea5fbb916dd649712efd1fe6a195efc8b3) @@ -15,7 +15,7 @@ true bin\Debug\ - 4 + 4 DEBUG;TRACE full x86 @@ -27,7 +27,7 @@ bin\Release\ - 4 + 4 TRACE true pdbonly @@ -132,6 +132,9 @@ + + + Index: src/Plugins/Wti/Wti.Plugin/FileImporter/PipingSoilProfilesImporter.cs =================================================================== diff -u --- src/Plugins/Wti/Wti.Plugin/FileImporter/PipingSoilProfilesImporter.cs (revision 0) +++ src/Plugins/Wti/Wti.Plugin/FileImporter/PipingSoilProfilesImporter.cs (revision a4e086ea5fbb916dd649712efd1fe6a195efc8b3) @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using DelftTools.Shell.Core; +using Wti.Data; +using WtiFormsResources = Wti.Forms.Properties.Resources; +using ApplicationResources = Wti.Plugin.Properties.Resources; + +namespace Wti.Plugin.FileImporter +{ + /// + /// Imports .soil files (SqlLite database files) created with the DSoilModel application. + /// + public class PipingSoilProfilesImporter : IFileImporter + { + public string Name + { + get + { + return WtiFormsResources.PipingSoilProfilesCollectionName; + } + } + + public string Category + { + get + { + return ApplicationResources.WtiApplicationName; + } + } + + public Bitmap Image + { + get + { + return WtiFormsResources.PipingSoilProfileIcon; + } + } + + public IEnumerable SupportedItemTypes + { + get + { + return new[] + { + typeof(IEnumerable) + }; + } + } + + public bool CanImportOnRootLevel + { + get + { + return false; + } + } + + public string FileFilter + { + get + { + return String.Format("{0} {1} (*.soil)|*.soil", + WtiFormsResources.PipingSoilProfilesCollectionName, ApplicationResources.SoilFileName); + } + } + + public string TargetDataDirectory { get; set; } + public bool ShouldCancel { get; set; } + public ImportProgressChangedDelegate ProgressChanged { get; set; } + + public bool OpenViewAfterImport + { + get + { + return false; + } + } + + public bool CanImportOn(object targetObject) + { + return targetObject is ICollection; + } + + public object ImportItem(string path, object target = null) + { + return target; + } + } +} \ No newline at end of file Index: src/Plugins/Wti/Wti.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u -r2cc167229383dbc03827939d66d50db5b651dba5 -ra4e086ea5fbb916dd649712efd1fe6a195efc8b3 --- src/Plugins/Wti/Wti.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 2cc167229383dbc03827939d66d50db5b651dba5) +++ src/Plugins/Wti/Wti.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a4e086ea5fbb916dd649712efd1fe6a195efc8b3) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18444 +// Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -70,6 +70,15 @@ } /// + /// Looks up a localized string similar to DSoilModel bestand. + /// + public static string SoilFileName { + get { + return ResourceManager.GetString("SoilFileName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Instrumentarium om de WTI toetsnorm mee uit te voeren.. /// public static string WtiApplicationDescription { Index: src/Plugins/Wti/Wti.Plugin/Properties/Resources.resx =================================================================== diff -u -r2cc167229383dbc03827939d66d50db5b651dba5 -ra4e086ea5fbb916dd649712efd1fe6a195efc8b3 --- src/Plugins/Wti/Wti.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 2cc167229383dbc03827939d66d50db5b651dba5) +++ src/Plugins/Wti/Wti.Plugin/Properties/Resources.resx (.../Resources.resx) (revision a4e086ea5fbb916dd649712efd1fe6a195efc8b3) @@ -138,4 +138,7 @@ Kommagescheiden bestand + + DSoilModel bestand + \ No newline at end of file Index: src/Plugins/Wti/Wti.Plugin/Wti.Plugin.csproj =================================================================== diff -u -r2ff69dfc67c77d80c1ed2f4f1f9bc0172e28e518 -ra4e086ea5fbb916dd649712efd1fe6a195efc8b3 --- src/Plugins/Wti/Wti.Plugin/Wti.Plugin.csproj (.../Wti.Plugin.csproj) (revision 2ff69dfc67c77d80c1ed2f4f1f9bc0172e28e518) +++ src/Plugins/Wti/Wti.Plugin/Wti.Plugin.csproj (.../Wti.Plugin.csproj) (revision a4e086ea5fbb916dd649712efd1fe6a195efc8b3) @@ -15,7 +15,7 @@ true bin\Debug\ - 4 + 4 DEBUG;TRACE full x86 @@ -27,7 +27,7 @@ bin\Release\ - 4 + 4 TRACE true pdbonly @@ -65,6 +65,7 @@ Properties\GlobalAssembly.cs + Index: src/Plugins/Wti/Wti.Plugin/WtiApplicationPlugin.cs =================================================================== diff -u -rbb61ed227cf79e994b84019096e4297b2fbd4527 -ra4e086ea5fbb916dd649712efd1fe6a195efc8b3 --- src/Plugins/Wti/Wti.Plugin/WtiApplicationPlugin.cs (.../WtiApplicationPlugin.cs) (revision bb61ed227cf79e994b84019096e4297b2fbd4527) +++ src/Plugins/Wti/Wti.Plugin/WtiApplicationPlugin.cs (.../WtiApplicationPlugin.cs) (revision a4e086ea5fbb916dd649712efd1fe6a195efc8b3) @@ -58,6 +58,7 @@ public override IEnumerable GetFileImporters() { yield return new PipingSurfaceLinesCsvImporter(); + yield return new PipingSoilProfilesImporter(); } } } \ No newline at end of file Index: test/Plugins/Wti/Wti.Plugin.Test/FileImporter/PipingSoilProfileImporterTest.cs =================================================================== diff -u --- test/Plugins/Wti/Wti.Plugin.Test/FileImporter/PipingSoilProfileImporterTest.cs (revision 0) +++ test/Plugins/Wti/Wti.Plugin.Test/FileImporter/PipingSoilProfileImporterTest.cs (revision a4e086ea5fbb916dd649712efd1fe6a195efc8b3) @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; + +using DelftTools.Shell.Core; + +using NUnit.Framework; + +using Rhino.Mocks; + +using Wti.Data; +using Wti.Plugin.FileImporter; +using WtiFormsResources = Wti.Forms.Properties.Resources; +using ApplicationResources = Wti.Plugin.Properties.Resources; + +namespace Wti.Plugin.Test.FileImporter +{ + [TestFixture] + public class PipingSoilProfilesImporterTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Prepare + var expectedFileFilter = String.Format("{0} {1} (*.soil)|*.soil", + WtiFormsResources.PipingSoilProfilesCollectionName, ApplicationResources.SoilFileName); + + // Call + var importer = new PipingSoilProfilesImporter(); + + // Assert + Assert.IsInstanceOf(importer); + Assert.AreEqual(WtiFormsResources.PipingSoilProfilesCollectionName, importer.Name); + Assert.AreEqual(ApplicationResources.WtiApplicationName, importer.Category); + Assert.AreEqual(16, importer.Image.Width); + Assert.AreEqual(16, importer.Image.Height); + CollectionAssert.AreEqual(new[] { typeof(IEnumerable) }, importer.SupportedItemTypes); + Assert.IsFalse(importer.CanImportOnRootLevel); + Assert.AreEqual(expectedFileFilter, importer.FileFilter); + Assert.IsNull(importer.TargetDataDirectory); + Assert.IsFalse(importer.ShouldCancel); + Assert.IsNull(importer.ProgressChanged); + Assert.IsFalse(importer.OpenViewAfterImport); + } + + [Test] + public void CanImportOn_TargetIsCollectionOfPipingSurfaceLines_ReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var validTarget = mocks.StrictMock>(); + mocks.ReplayAll(); + + var importer = new PipingSoilProfilesImporter(); + + // Call + var importAllowed = importer.CanImportOn(validTarget); + + // Assert + Assert.IsTrue(importAllowed); + mocks.VerifyAll(); // Expect no calls on mocks. + } + + [Test] + public void CanImportOn_InvalidTarget_ReturnFalse() + { + // Setup + var mocks = new MockRepository(); + var invalidTarget = mocks.StrictMock>(); + mocks.ReplayAll(); + + var importer = new PipingSoilProfilesImporter(); + + // Call + var importAllowed = importer.CanImportOn(invalidTarget); + + // Assert + Assert.IsFalse(importAllowed); + mocks.VerifyAll(); // Expect no calls on mocks. + } + + [Test] + public void ImportItem_ImportingToValidTargetWithValidFile_ImportSurfaceLinesToCollection() + { + // Setup + const string validFilePath = ""; + var piping = new PipingFailureMechanism(); + + var importer = new PipingSoilProfilesImporter(); + + var importTarget = piping.SoilProfiles; + + // Precondition + Assert.IsTrue(importer.CanImportOn(importTarget)); + + // Call + var importedItem = importer.ImportItem(validFilePath, importTarget); + + // Assert + Assert.AreSame(importTarget, importedItem); + } + } +} \ No newline at end of file Index: test/Plugins/Wti/Wti.Plugin.Test/Wti.Plugin.Test.csproj =================================================================== diff -u -r2ff69dfc67c77d80c1ed2f4f1f9bc0172e28e518 -ra4e086ea5fbb916dd649712efd1fe6a195efc8b3 --- test/Plugins/Wti/Wti.Plugin.Test/Wti.Plugin.Test.csproj (.../Wti.Plugin.Test.csproj) (revision 2ff69dfc67c77d80c1ed2f4f1f9bc0172e28e518) +++ test/Plugins/Wti/Wti.Plugin.Test/Wti.Plugin.Test.csproj (.../Wti.Plugin.Test.csproj) (revision a4e086ea5fbb916dd649712efd1fe6a195efc8b3) @@ -15,7 +15,7 @@ true bin\Debug\ - 4 + 4 DEBUG;TRACE full x86 @@ -24,7 +24,7 @@ bin\Release\ - 4 + 4 TRACE true pdbonly @@ -52,6 +52,7 @@ +