Index: Core/Common/src/Core.Common.Gui/Appenders/RenderedMessageLogAppender.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/Appenders/RenderedMessageLogAppender.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/Appenders/RenderedMessageLogAppender.cs (revision eff889238a2ecfab9aacabe9b99a35c6989006d9) @@ -0,0 +1,78 @@ +// 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; + +using log4net.Appender; +using log4net.Core; + +namespace Core.Common.Gui.Appenders +{ + /// + /// Singleton log-appender for Log4Net that is used to fill a 'Run-report' when executing + /// a particular piece of code. + /// + public class RenderedMessageLogAppender : AppenderSkeleton + { + private Action appendMessageLineAction; + + /// + /// Initializes the singleton. + /// + public RenderedMessageLogAppender() // Constructor might be marked as unused, but is called in app.config. + { + Instance = this; + } + + /// + /// The singleton value. + /// + public static RenderedMessageLogAppender Instance { get; private set; } + + /// + /// The action to be called when a new message is logged. + /// + public Action AppendMessageLineAction + { + get + { + return appendMessageLineAction; + } + set + { + if (value != null && appendMessageLineAction != null) + { + throw new InvalidOperationException("An action is already set"); + } + + appendMessageLineAction = value; + } + } + + protected override void Append(LoggingEvent loggingEvent) + { + if (AppendMessageLineAction != null) + { + AppendMessageLineAction(loggingEvent.RenderedMessage); + } + } + } +} \ No newline at end of file Fisheye: Tag eff889238a2ecfab9aacabe9b99a35c6989006d9 refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Gui/Appenders/RunReportLogAppender.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj =================================================================== diff -u -ref1c61d94f2aec3b4ff32fcf03253d7ad386c8e5 -reff889238a2ecfab9aacabe9b99a35c6989006d9 --- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision ef1c61d94f2aec3b4ff32fcf03253d7ad386c8e5) +++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision eff889238a2ecfab9aacabe9b99a35c6989006d9) @@ -111,7 +111,7 @@ Properties\GlobalAssembly.cs - + Index: Core/Common/src/Core.Common.Gui/Forms/ProgressDialog/ActivityProgressDialog.cs =================================================================== diff -u -r4512af7782ee31b36941bb280b54d9da2953dd71 -reff889238a2ecfab9aacabe9b99a35c6989006d9 --- Core/Common/src/Core.Common.Gui/Forms/ProgressDialog/ActivityProgressDialog.cs (.../ActivityProgressDialog.cs) (revision 4512af7782ee31b36941bb280b54d9da2953dd71) +++ Core/Common/src/Core.Common.Gui/Forms/ProgressDialog/ActivityProgressDialog.cs (.../ActivityProgressDialog.cs) (revision eff889238a2ecfab9aacabe9b99a35c6989006d9) @@ -90,9 +90,9 @@ try { - if (RunReportLogAppender.Instance != null) + if (RenderedMessageLogAppender.Instance != null) { - RunReportLogAppender.Instance.AppendMessageLineAction = message => runningActivity.LogMessages.Add(message); + RenderedMessageLogAppender.Instance.AppendMessageLineAction = message => runningActivity.LogMessages.Add(message); } runningActivity.ProgressChanged += ActivityOnProgressChanged; @@ -102,9 +102,9 @@ } finally { - if (RunReportLogAppender.Instance != null) + if (RenderedMessageLogAppender.Instance != null) { - RunReportLogAppender.Instance.AppendMessageLineAction = null; + RenderedMessageLogAppender.Instance.AppendMessageLineAction = null; } runningActivity.ProgressChanged -= ActivityOnProgressChanged; Index: Core/Common/test/Core.Common.Gui.Test/Appenders/RenderedMessageLogAppenderTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/Appenders/RenderedMessageLogAppenderTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/Appenders/RenderedMessageLogAppenderTest.cs (revision eff889238a2ecfab9aacabe9b99a35c6989006d9) @@ -0,0 +1,145 @@ +using System; + +using Core.Common.Gui.Appenders; + +using log4net.Appender; +using log4net.Core; +using log4net.Util; + +using NUnit.Framework; + +namespace Core.Common.Gui.Test.Appenders +{ + [TestFixture] + public class RenderedMessageLogAppenderTest + { + private Action originalAppendMessageLineAction; + + [TestFixtureSetUp] + public void TestFixtureSetUp() + { + if (RenderedMessageLogAppender.Instance != null) + { + originalAppendMessageLineAction = RenderedMessageLogAppender.Instance.AppendMessageLineAction; + RenderedMessageLogAppender.Instance.AppendMessageLineAction = null; + } + } + + [TestFixtureTearDown] + public void TestFixtureTearDown() + { + RenderedMessageLogAppender.Instance.AppendMessageLineAction = originalAppendMessageLineAction; + } + + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var appender = new RenderedMessageLogAppender(); + + // Assert + Assert.IsInstanceOf(appender); + Assert.IsNull(appender.AppendMessageLineAction); + Assert.IsInstanceOf(appender.ErrorHandler, + "Appender has default Log4Net error handler."); + Assert.IsNull(appender.FilterHead); + Assert.IsNull(appender.Layout); + Assert.IsNull(appender.Name); + Assert.IsNull(appender.Threshold); + + Assert.AreSame(appender, RenderedMessageLogAppender.Instance); + } + + [Test] + public void DoAppend_WithAppendMessageLineActionSet_ActionCalledForText() + { + // Setup + const string messagetext = "messageText"; + + var logEventData = new LoggingEventData + { + Message = messagetext + }; + var logEvent = new LoggingEvent(logEventData); + + int actionCallCount = 0; + var appender = new RenderedMessageLogAppender + { + AppendMessageLineAction = s => + { + Assert.AreEqual(messagetext, s); + actionCallCount++; + } + }; + + // Call + appender.DoAppend(logEvent); + + // Assert + Assert.AreEqual(1, actionCallCount); + } + + [Test] + public void DoAppend_WithoutAppendMessageLineActionSet_DoNotThrow() + { + // Setup + const string messagetext = "messageText"; + + var logEventData = new LoggingEventData + { + Message = messagetext + }; + var logEvent = new LoggingEvent(logEventData); + + var appender = new RenderedMessageLogAppender(); + + // Call + TestDelegate call = () => appender.DoAppend(logEvent); + + // Assert + Assert.DoesNotThrow(call); + } + + [Test] + public void AppendMessageLineAction_SetTwoActions_ThrowInvalidOperationException() + { + // Setup + var appender = new RenderedMessageLogAppender + { + AppendMessageLineAction = s => + { + // Do nothing + } + }; + + // Call + TestDelegate call = () => appender.AppendMessageLineAction = s => + { + // Do nothing again. + }; + + // Assert + var message = Assert.Throws(call).Message; + Assert.AreEqual("An action is already set", message); + } + + [Test] + public void AppendMessageLineAction_SetToNullWhenAlreadyHasAction_SetActionToNull() + { + // Setup + var appender = new RenderedMessageLogAppender + { + AppendMessageLineAction = s => + { + // Do nothing + } + }; + + // Call + appender.AppendMessageLineAction = null; + + // Assert + Assert.IsNull(appender.AppendMessageLineAction); + } + } +} \ No newline at end of file Fisheye: Tag eff889238a2ecfab9aacabe9b99a35c6989006d9 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Gui.Test/Appenders/RunReportLogAppenderTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj =================================================================== diff -u -ref1c61d94f2aec3b4ff32fcf03253d7ad386c8e5 -reff889238a2ecfab9aacabe9b99a35c6989006d9 --- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision ef1c61d94f2aec3b4ff32fcf03253d7ad386c8e5) +++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision eff889238a2ecfab9aacabe9b99a35c6989006d9) @@ -91,7 +91,7 @@ - + Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs =================================================================== diff -u -r9d1ffc9bd1a9c392c6b832422649a0ad2f5ff59c -reff889238a2ecfab9aacabe9b99a35c6989006d9 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs (.../PipingSurfaceLinesCsvImporter.cs) (revision 9d1ffc9bd1a9c392c6b832422649a0ad2f5ff59c) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs (.../PipingSurfaceLinesCsvImporter.cs) (revision eff889238a2ecfab9aacabe9b99a35c6989006d9) @@ -121,7 +121,6 @@ } var importCharacteristicPointsResult = ReadCharacteristicPoints(filePath); - if (importCharacteristicPointsResult.CriticalErrorOccurred) { return false;