Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r265c86f31e68d374bbeda5379b678ae774baca9c -rda65cd978b7ca2979e5ecf0132545b5028c1d976
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 265c86f31e68d374bbeda5379b678ae774baca9c)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision da65cd978b7ca2979e5ecf0132545b5028c1d976)
@@ -67,7 +67,6 @@
-
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx
===================================================================
diff -u -ra01c8d560f9fc30520fc717d83888a3bf6974cc9 -rda65cd978b7ca2979e5ecf0132545b5028c1d976
--- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision a01c8d560f9fc30520fc717d83888a3bf6974cc9)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision da65cd978b7ca2979e5ecf0132545b5028c1d976)
@@ -4,7 +4,7 @@
-
+
Fisheye: Tag da65cd978b7ca2979e5ecf0132545b5028c1d976 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Exceptions/InvalidFileException.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs
===================================================================
diff -u -r265c86f31e68d374bbeda5379b678ae774baca9c -rda65cd978b7ca2979e5ecf0132545b5028c1d976
--- Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision 265c86f31e68d374bbeda5379b678ae774baca9c)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision da65cd978b7ca2979e5ecf0132545b5028c1d976)
@@ -4,6 +4,7 @@
using System.IO;
using Application.Ringtoets.Storage.Converters;
using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Exceptions;
using Application.Ringtoets.Storage.Properties;
using Core.Common.Base.Data;
using Core.Common.Utils;
@@ -21,7 +22,8 @@
/// Creates a new instance of .
///
/// Path to database file.
- /// is invalid.
+ /// Thrown when is invalid.
+ /// Thrown when does not exist.
public StorageSqLite(string databaseFilePath)
: base(databaseFilePath)
{
@@ -62,6 +64,12 @@
///
/// to save.
/// Returns the number of changes that were saved in .
+ /// Thrown when
+ ///
+ /// - Saving the to the database failed.
+ /// - The connection to the database file failed.
+ ///
+ ///
public int SaveProjectAs(Project project)
{
using (var dbContext = new RingtoetsEntities(ConnectionString))
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -rfcaefe32db71396013a5bad171e953921d2d0c29 -rda65cd978b7ca2979e5ecf0132545b5028c1d976
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision fcaefe32db71396013a5bad171e953921d2d0c29)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision da65cd978b7ca2979e5ecf0132545b5028c1d976)
@@ -73,7 +73,7 @@
-
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converter/ProjectEntityConverterTest.cs
===================================================================
diff -u -r265c86f31e68d374bbeda5379b678ae774baca9c -rda65cd978b7ca2979e5ecf0132545b5028c1d976
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converter/ProjectEntityConverterTest.cs (.../ProjectEntityConverterTest.cs) (revision 265c86f31e68d374bbeda5379b678ae774baca9c)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converter/ProjectEntityConverterTest.cs (.../ProjectEntityConverterTest.cs) (revision da65cd978b7ca2979e5ecf0132545b5028c1d976)
@@ -15,7 +15,7 @@
public class ProjectEntityConverterTest
{
[Test]
- public void GetProject_ProjectEntity_Project()
+ public void GetProject_DbSetWithValidProjectEntity_ReturnsTheProjectEntityAsProject()
{
// Setup
const long projectId = 1;
@@ -32,13 +32,13 @@
});
// Call
- var project = ProjectEntityConverter.GetProject(projectEntities);
+ Project project = ProjectEntityConverter.GetProject(projectEntities);
// Assert
Assert.IsInstanceOf(project);
Assert.AreEqual(project.StorageId, projectId);
- Assert.That(project.Name == projectEntity.Name);
- Assert.That(project.Description == projectEntity.Description);
+ Assert.AreEqual(project.Name, projectEntity.Name);
+ Assert.AreEqual(project.Description, projectEntity.Description);
Assert.IsEmpty(project.Items);
}
@@ -130,7 +130,7 @@
}
[Test]
- public void UpdateProjectEntity_Project_ProjectEntity()
+ public void UpdateProjectEntity_WithSingleProject_ProjectEntriesEqualToProject()
{
// Setup
const long projectId = 1;
@@ -147,18 +147,22 @@
ProjectEntityId = projectId
}
};
- var projectEntities = GetDbSetTest(projectEnties);
+ IDbSet projectEntities = GetDbSetTest(projectEnties);
// Call
ProjectEntityConverter.UpdateProjectEntity(projectEntities, project);
// Assert
Assert.IsInstanceOf(project);
- var projectEntitiesArray = projectEntities.ToList();
+ List projectEntitiesArray = projectEntities.ToList();
Assert.AreEqual(projectEntitiesArray.Count, 1);
- Assert.AreEqual(project.StorageId, projectEntitiesArray[0].ProjectEntityId);
- Assert.AreEqual(project.Name, projectEntitiesArray[0].Name);
- Assert.AreEqual(project.Description, projectEntitiesArray[0].Description);
+
+ ProjectEntity projectEntity = projectEntitiesArray[0];
+
+ Assert.AreEqual(project.StorageId, projectEntity.ProjectEntityId);
+ Assert.AreEqual(project.Name, projectEntity.Name);
+ Assert.AreEqual(project.Description, projectEntity.Description);
+ Assert.AreNotEqual(project, projectEntity);
}
private static IDbSet GetDbSetTest(IList data) where T : class
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/DbContext/ProjectEntityTest.cs
===================================================================
diff -u -rfcaefe32db71396013a5bad171e953921d2d0c29 -rda65cd978b7ca2979e5ecf0132545b5028c1d976
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/DbContext/ProjectEntityTest.cs (.../ProjectEntityTest.cs) (revision fcaefe32db71396013a5bad171e953921d2d0c29)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/DbContext/ProjectEntityTest.cs (.../ProjectEntityTest.cs) (revision da65cd978b7ca2979e5ecf0132545b5028c1d976)
@@ -10,10 +10,10 @@
public void DefaultConstructor_Always_ExpectedValues()
{
// Call
- var projectEntity = new ProjectEntity();
+ ProjectEntity projectEntity = new ProjectEntity();
// Assert
- Assert.AreEqual(new long(), projectEntity.ProjectEntityId);
+ Assert.AreEqual(0, projectEntity.ProjectEntityId);
Assert.IsNull(projectEntity.LastUpdated);
}
@@ -42,10 +42,12 @@
}
[Test]
- public void GetProperties_WithNullableData_ReturnExpectedValues()
+ [TestCase(null)]
+ [TestCase(0L)]
+ [TestCase(1234L)]
+ public void LastUpdated_DifferentValues_ReturnExpectedValues(long? someTimestamp)
{
// Setup
- long? someTimestamp = null;
var projectEntity = new ProjectEntity
{
LastUpdated = someTimestamp
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Exceptions/EntityNotFoundExceptionTest.cs
===================================================================
diff -u -rfcaefe32db71396013a5bad171e953921d2d0c29 -rda65cd978b7ca2979e5ecf0132545b5028c1d976
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Exceptions/EntityNotFoundExceptionTest.cs (.../EntityNotFoundExceptionTest.cs) (revision fcaefe32db71396013a5bad171e953921d2d0c29)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Exceptions/EntityNotFoundExceptionTest.cs (.../EntityNotFoundExceptionTest.cs) (revision da65cd978b7ca2979e5ecf0132545b5028c1d976)
@@ -11,12 +11,13 @@
public void DefaultConstructor_InnerExceptionNullAndMessageDefault()
{
// Setup
- var expectedMessage = String.Format("Exception of type '{0}' was thrown.", typeof(EntityNotFoundException).FullName);
+ string expectedMessage = String.Format("Exception of type '{0}' was thrown.", typeof(EntityNotFoundException).FullName);
// Call
- var exception = new EntityNotFoundException();
+ EntityNotFoundException exception = new EntityNotFoundException();
// Assert
+ Assert.IsInstanceOf(exception);
Assert.IsNull(exception.InnerException);
Assert.AreEqual(expectedMessage, exception.Message);
}
@@ -25,10 +26,10 @@
public void Constructor_WithCustomMessage_InnerExceptionNullAndMessageSetToCustom()
{
// Setup
- var expectedMessage ="Some exception message";
+ const string expectedMessage = "Some exception message";
// Call
- var exception = new EntityNotFoundException(expectedMessage);
+ EntityNotFoundException exception = new EntityNotFoundException(expectedMessage);
// Assert
Assert.IsNull(exception.InnerException);
@@ -39,11 +40,11 @@
public void Constructor_WithCustomMessageAndInnerException_InnerExceptionSetAndMessageSetToCustom()
{
// Setup
- var expectedMessage = "Some exception message";
- var expectedInnerException = new Exception();
+ const string expectedMessage = "Some exception message";
+ Exception expectedInnerException = new Exception();
// Call
- var exception = new EntityNotFoundException(expectedMessage, expectedInnerException);
+ EntityNotFoundException exception = new EntityNotFoundException(expectedMessage, expectedInnerException);
// Assert
Assert.AreSame(expectedInnerException, exception.InnerException);
Fisheye: Tag da65cd978b7ca2979e5ecf0132545b5028c1d976 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Exceptions/InvalidFileException.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Exceptions/UpdateDatabaseExceptionTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Exceptions/UpdateDatabaseExceptionTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Exceptions/UpdateDatabaseExceptionTest.cs (revision da65cd978b7ca2979e5ecf0132545b5028c1d976)
@@ -0,0 +1,53 @@
+using System;
+using Application.Ringtoets.Storage.Exceptions;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.Test.Exceptions
+{
+ [TestFixture]
+ public class UpdateDatabaseExceptionTest
+ {
+ [Test]
+ public void DefaultConstructor_InnerExceptionNullAndMessageDefault()
+ {
+ // Setup
+ string expectedMessage = String.Format("Exception of type '{0}' was thrown.", typeof(UpdateDatabaseException).FullName);
+
+ // Call
+ UpdateDatabaseException exception = new UpdateDatabaseException();
+
+ // Assert
+ Assert.IsNull(exception.InnerException);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
+ [Test]
+ public void Constructor_WithCustomMessage_InnerExceptionNullAndMessageSetToCustom()
+ {
+ // Setup
+ const string expectedMessage = "Some exception message";
+
+ // Call
+ UpdateDatabaseException exception = new UpdateDatabaseException(expectedMessage);
+
+ // Assert
+ Assert.IsNull(exception.InnerException);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
+ [Test]
+ public void Constructor_WithCustomMessageAndInnerException_InnerExceptionSetAndMessageSetToCustom()
+ {
+ // Setup
+ const string expectedMessage = "Some exception message";
+ Exception expectedInnerException = new Exception();
+
+ // Call
+ UpdateDatabaseException exception = new UpdateDatabaseException(expectedMessage, expectedInnerException);
+
+ // Assert
+ Assert.AreSame(expectedInnerException, exception.InnerException);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSQLiteTest.cs
===================================================================
diff -u -rafc121510f818769b49ae9fd3a7297524aff1d65 -rda65cd978b7ca2979e5ecf0132545b5028c1d976
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSQLiteTest.cs (.../StorageSQLiteTest.cs) (revision afc121510f818769b49ae9fd3a7297524aff1d65)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSQLiteTest.cs (.../StorageSQLiteTest.cs) (revision da65cd978b7ca2979e5ecf0132545b5028c1d976)
@@ -2,7 +2,6 @@
using System.IO;
using Core.Common.Base.Data;
using Core.Common.TestUtil;
-using Core.Common.Utils.Builders;
using NUnit.Framework;
using UtilsResources = Core.Common.Utils.Properties.Resources;
@@ -15,7 +14,7 @@
[Test]
[TestCase("empty.rt")]
- public void Constructor_validPath_NewInstance(string validPath)
+ public void Constructor_ValidPath_NewInstance(string validPath)
{
// Setup
var dbFile = Path.Combine(testDataPath, validPath);
@@ -25,40 +24,43 @@
// Call
TestDelegate test = () => new StorageSqLite(dbFile);
+
+ // Assert
Assert.DoesNotThrow(test);
}
[Test]
[TestCase(null)]
[TestCase("")]
- public void Constructor_FileNullOrEmpty_throwsFileNotFoundException(string invalidPath)
+ 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);
+ ArgumentException exception = Assert.Throws(test);
+ string 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)
+ public void Constructor_InvalidPath_ThrowsFileNotFoundException(string invalidPath)
{
// Call
TestDelegate test = () => new StorageSqLite(invalidPath);
// Assert
- var exception = Assert.Throws(test);
- var expectedMessage = new FileReaderErrorMessageBuilder(invalidPath).Build(UtilsResources.Error_File_does_not_exist);
+ FileNotFoundException exception = Assert.Throws(test);
+ string expectedMessage = String.Format("Fout bij het lezen van bestand '{0}': {1}",
+ invalidPath, UtilsResources.Error_File_does_not_exist);
Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
[TestCase("ValidRingtoetsDatabase.rt")]
- public void TestConnection_validConnection_ReturnsTrue(string validPath)
+ public void TestConnection_ValidConnection_ReturnsTrue(string validPath)
{
// Setup
var dbFile = Path.Combine(testDataPath, validPath);
@@ -67,13 +69,15 @@
Assert.IsTrue(File.Exists(dbFile), "Precondition: file must exist.");
// Call
- var storage = new StorageSqLite(dbFile);
+ StorageSqLite storage = new StorageSqLite(dbFile);
+
+ // Assert
Assert.True(storage.TestConnection());
}
[Test]
[TestCase("empty.rt")]
- public void TestConnection_invalidConnection_ReturnsFalse(string invalidPath)
+ public void TestConnection_InvalidConnection_ReturnsFalse(string invalidPath)
{
// Setup
var dbFile = Path.Combine(testDataPath, invalidPath);
@@ -82,25 +86,28 @@
Assert.IsTrue(File.Exists(dbFile), "Precondition: file must exist.");
// Call
- var storage = new StorageSqLite(dbFile);
+ StorageSqLite storage = new StorageSqLite(dbFile);
+
+ // Assert
Assert.False(storage.TestConnection());
}
[Test]
[TestCase("ValidRingtoetsDatabase.rt")]
- public void LoadProject_validDatabase_ReturnsProject(string validPath)
+ 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();
+ // Call
+ Project loadedProject = storage.LoadProject();
+
+ // Assert
Assert.IsInstanceOf(loadedProject);
}
}
Index: Core/Common/src/Core.Common.Utils/FileUtils.cs
===================================================================
diff -u -r654d3a712eedbdeea718dc0448c5544f09e053cd -rda65cd978b7ca2979e5ecf0132545b5028c1d976
--- Core/Common/src/Core.Common.Utils/FileUtils.cs (.../FileUtils.cs) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd)
+++ Core/Common/src/Core.Common.Utils/FileUtils.cs (.../FileUtils.cs) (revision da65cd978b7ca2979e5ecf0132545b5028c1d976)
@@ -1,21 +1,21 @@
using System;
using System.IO;
-using Core.Common.Utils.Properties;
using Core.Common.Utils.Builders;
+using Core.Common.Utils.Properties;
namespace Core.Common.Utils
{
///
/// Class with reusable File related utility methods.
///
- public static class FileUtils
+ public static class FileUtils
{
///
/// Validates the file path.
///
/// The file path to be validated.
/// is invalid.
- public static void ValidateFilePath(string path)
+ public static void ValidateFilePath(string path)
{
if (String.IsNullOrWhiteSpace(path))
{
Index: Core/Common/test/Core.Common.Integration.Test/Ringtoets/Application.Ringtoets/RingtoetsGuiIntegrationTest.cs
===================================================================
diff -u -r8404b9bd4e87e4a097a982ddccba6ecfa5aeec32 -rda65cd978b7ca2979e5ecf0132545b5028c1d976
--- Core/Common/test/Core.Common.Integration.Test/Ringtoets/Application.Ringtoets/RingtoetsGuiIntegrationTest.cs (.../RingtoetsGuiIntegrationTest.cs) (revision 8404b9bd4e87e4a097a982ddccba6ecfa5aeec32)
+++ Core/Common/test/Core.Common.Integration.Test/Ringtoets/Application.Ringtoets/RingtoetsGuiIntegrationTest.cs (.../RingtoetsGuiIntegrationTest.cs) (revision da65cd978b7ca2979e5ecf0132545b5028c1d976)
@@ -1,11 +1,11 @@
using System.Linq;
+using System.Windows.Controls;
using Core.Common.Gui;
using Core.Common.Gui.Forms.MainWindow;
using Core.Common.TestUtil;
using Core.Plugins.ProjectExplorer;
using Core.Plugins.SharpMapGis;
using NUnit.Framework;
-using Control = System.Windows.Controls.Control;
namespace Core.Common.Integration.Test.Ringtoets.Application.Ringtoets
{
@@ -20,13 +20,14 @@
[Test]
[RequiresSTA]
- public void ClosingEmptyProjectShouldNotGiveException()
+ public void CloseProject_EmptyProject_DoesNotThrowException()
{
using (var gui = new RingtoetsGui())
{
gui.MainWindow = new MainWindow(gui);
gui.Run();
- gui.CommandHandler.CloseProject(); //should not trigger exception
+ TestDelegate closeProject = () => gui.CommandHandler.CloseProject();
+ Assert.DoesNotThrow(closeProject);
}
}