Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj
===================================================================
diff -u -rf3e15928caffd4336c97f5fa3de495a5a05bf6b8 -r50159826a713183c37ff03330d65d591dcdfd71b
--- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision f3e15928caffd4336c97f5fa3de495a5a05bf6b8)
+++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 50159826a713183c37ff03330d65d591dcdfd71b)
@@ -122,6 +122,7 @@
+
Index: Core/Common/test/Core.Common.Gui.Test/Plugin/ImportInfoTest.cs
===================================================================
diff -u -r7fb7b486bcbdd216ef834eaed0c89a1362e119e2 -r50159826a713183c37ff03330d65d591dcdfd71b
--- Core/Common/test/Core.Common.Gui.Test/Plugin/ImportInfoTest.cs (.../ImportInfoTest.cs) (revision 7fb7b486bcbdd216ef834eaed0c89a1362e119e2)
+++ Core/Common/test/Core.Common.Gui.Test/Plugin/ImportInfoTest.cs (.../ImportInfoTest.cs) (revision 50159826a713183c37ff03330d65d591dcdfd71b)
@@ -44,6 +44,7 @@
Assert.IsNull(info.Category);
Assert.IsNull(info.Image);
Assert.IsNull(info.FileFilterGenerator);
+ Assert.IsNull(info.VerifyUpdates);
}
[Test]
@@ -60,6 +61,7 @@
Assert.IsNull(info.Category);
Assert.IsNull(info.Image);
Assert.IsNull(info.FileFilterGenerator);
+ Assert.IsNull(info.VerifyUpdates);
}
[Test]
@@ -82,7 +84,8 @@
Name = name,
Category = category,
Image = image,
- FileFilterGenerator = generator
+ FileFilterGenerator = generator,
+ VerifyUpdates = i => true
};
// Precondition
@@ -102,6 +105,8 @@
Assert.AreEqual(category, info.Category);
Assert.AreSame(image, info.Image);
Assert.AreEqual(generator, info.FileFilterGenerator);
+ Assert.IsNotNull(info.VerifyUpdates);
+ Assert.IsTrue(convertedInfo.VerifyUpdates(12));
mocks.VerifyAll();
}
@@ -122,13 +127,14 @@
Assert.IsInstanceOf(convertedInfo);
Assert.AreEqual(typeof(int), convertedInfo.DataType);
Assert.IsNotNull(convertedInfo.CreateFileImporter);
- Assert.IsNull(convertedInfo.CreateFileImporter(new object(), ""));
+ Assert.IsNull(convertedInfo.CreateFileImporter(12, ""));
Assert.IsNotNull(convertedInfo.IsEnabled);
- Assert.IsTrue(convertedInfo.IsEnabled(new object()));
+ Assert.IsTrue(convertedInfo.IsEnabled(12));
Assert.IsNull(info.Name);
Assert.IsNull(info.Category);
Assert.IsNull(info.Image);
Assert.IsNull(info.FileFilterGenerator);
+ Assert.IsNull(info.VerifyUpdates);
}
}
}
\ No newline at end of file
Index: Core/Common/test/Core.Common.Gui.Test/Plugin/UpdateInfoTest.cs
===================================================================
diff -u
--- Core/Common/test/Core.Common.Gui.Test/Plugin/UpdateInfoTest.cs (revision 0)
+++ Core/Common/test/Core.Common.Gui.Test/Plugin/UpdateInfoTest.cs (revision 50159826a713183c37ff03330d65d591dcdfd71b)
@@ -0,0 +1,147 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using Core.Common.Base.IO;
+using Core.Common.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+
+namespace Core.Common.Gui.Test.Plugin
+{
+ [TestFixture]
+ public class UpdateInfoTest
+ {
+ [Test]
+ public void DefaultConstructor_ExpectedValues()
+ {
+ // Call
+ var info = new UpdateInfo();
+
+ // Assert
+ Assert.IsNull(info.DataType);
+ Assert.IsNull(info.CreateFileImporter);
+ Assert.IsNull(info.IsEnabled);
+ Assert.IsNull(info.Name);
+ Assert.IsNull(info.Category);
+ Assert.IsNull(info.Image);
+ Assert.IsNull(info.FileFilterGenerator);
+ Assert.IsNull(info.CurrentPath);
+ Assert.IsNull(info.VerifyUpdates);
+ }
+
+ [Test]
+ public void DefaultGenericConstructor_ExpectedValues()
+ {
+ // Call
+ var info = new UpdateInfo();
+
+ // Assert
+ Assert.AreEqual(typeof(int), info.DataType);
+ Assert.IsNull(info.CreateFileImporter);
+ Assert.IsNull(info.IsEnabled);
+ Assert.IsNull(info.Name);
+ Assert.IsNull(info.Category);
+ Assert.IsNull(info.Image);
+ Assert.IsNull(info.FileFilterGenerator);
+ Assert.IsNull(info.CurrentPath);
+ Assert.IsNull(info.VerifyUpdates);
+ }
+
+ [Test]
+ public void ImplicitOperator_OptionalDelegatesAndPropertiesSet_UpdateInfoFullyConverted()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var fileUpdateer = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ const string name = "name";
+ const string category = "category";
+ const string path = "somePath";
+ var image = new Bitmap(16, 16);
+ var generator = new FileFilterGenerator();
+
+ var info = new UpdateInfo
+ {
+ CreateFileImporter = (data, filePath) => fileUpdateer,
+ IsEnabled = data => false,
+ Name = name,
+ Category = category,
+ Image = image,
+ FileFilterGenerator = generator,
+ VerifyUpdates = i => true,
+ CurrentPath = i => path
+ };
+
+ // Precondition
+ Assert.IsInstanceOf>(info);
+
+ // Call
+ UpdateInfo convertedInfo = info;
+
+ // Assert
+ Assert.IsInstanceOf(convertedInfo);
+ Assert.AreEqual(typeof(int), convertedInfo.DataType);
+ Assert.IsNotNull(convertedInfo.CreateFileImporter);
+ Assert.AreSame(fileUpdateer, convertedInfo.CreateFileImporter(12, ""));
+ Assert.IsNotNull(convertedInfo.IsEnabled);
+ Assert.IsFalse(convertedInfo.IsEnabled(12));
+ Assert.AreEqual(name, info.Name);
+ Assert.AreEqual(category, info.Category);
+ Assert.AreSame(image, info.Image);
+ Assert.AreEqual(generator, info.FileFilterGenerator);
+ Assert.IsNotNull(convertedInfo.VerifyUpdates);
+ Assert.IsTrue(convertedInfo.VerifyUpdates(12));
+ Assert.IsNotNull(convertedInfo.CurrentPath);
+ Assert.AreEqual(path, convertedInfo.CurrentPath(12));
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ImplicitOperator_NoneOfTheOptionalDelegatesAndPropertiesSet_UpdateInfoFullyConverted()
+ {
+ // Setup
+ var info = new UpdateInfo();
+
+ // Precondition
+ Assert.IsInstanceOf>(info);
+
+ // Call
+ UpdateInfo convertedInfo = info;
+
+ // Assert
+ Assert.IsInstanceOf(convertedInfo);
+ Assert.AreEqual(typeof(int), convertedInfo.DataType);
+ Assert.IsNotNull(convertedInfo.CreateFileImporter);
+ Assert.IsNull(convertedInfo.CreateFileImporter(12, ""));
+ Assert.IsNotNull(convertedInfo.IsEnabled);
+ Assert.IsTrue(convertedInfo.IsEnabled(12));
+ Assert.IsNull(info.Name);
+ Assert.IsNull(info.Category);
+ Assert.IsNull(info.Image);
+ Assert.IsNull(info.FileFilterGenerator);
+ Assert.IsNull(info.CurrentPath);
+ Assert.IsNull(info.VerifyUpdates);
+ }
+ }
+}
\ No newline at end of file