From 4b84a4612ad4f9dcaf3d45b4c5f3820cfc253cd9 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Wed, 24 Oct 2018 15:55:22 +0200 Subject: [PATCH] jj: Add Tests for Modules.Logging --- DDMonorepo.sln | 7 + Modules.Logging.Test/ConstructorUnitTest.vb | 52 +++++++ Modules.Logging.Test/Logging.Test.vbproj | 133 ++++++++++++++++++ .../My Project/Application.Designer.vb | 13 ++ .../My Project/Application.myapp | 10 ++ .../My Project/AssemblyInfo.vb | 18 +++ .../My Project/Resources.Designer.vb | 63 +++++++++ .../My Project/Resources.resx | 117 +++++++++++++++ .../My Project/Settings.Designer.vb | 73 ++++++++++ .../My Project/Settings.settings | 7 + Modules.Logging.Test/packages.config | 5 + 11 files changed, 498 insertions(+) create mode 100644 Modules.Logging.Test/ConstructorUnitTest.vb create mode 100644 Modules.Logging.Test/Logging.Test.vbproj create mode 100644 Modules.Logging.Test/My Project/Application.Designer.vb create mode 100644 Modules.Logging.Test/My Project/Application.myapp create mode 100644 Modules.Logging.Test/My Project/AssemblyInfo.vb create mode 100644 Modules.Logging.Test/My Project/Resources.Designer.vb create mode 100644 Modules.Logging.Test/My Project/Resources.resx create mode 100644 Modules.Logging.Test/My Project/Settings.Designer.vb create mode 100644 Modules.Logging.Test/My Project/Settings.settings create mode 100644 Modules.Logging.Test/packages.config diff --git a/DDMonorepo.sln b/DDMonorepo.sln index 2b5c8733..6f8f6ebc 100644 --- a/DDMonorepo.sln +++ b/DDMonorepo.sln @@ -41,6 +41,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Licenses", "Licenses", "{59 NLOG-LICENSE.txt = NLOG-LICENSE.txt EndProjectSection EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Logging.Test", "Modules.Logging.Test\Logging.Test.vbproj", "{3207D8E7-36E3-4714-9B03-7B5B3D6D351A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -91,6 +93,10 @@ Global {991D0231-4623-496D-8BD0-9CA906029CBC}.Debug|Any CPU.Build.0 = Debug|Any CPU {991D0231-4623-496D-8BD0-9CA906029CBC}.Release|Any CPU.ActiveCfg = Release|Any CPU {991D0231-4623-496D-8BD0-9CA906029CBC}.Release|Any CPU.Build.0 = Release|Any CPU + {3207D8E7-36E3-4714-9B03-7B5B3D6D351A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3207D8E7-36E3-4714-9B03-7B5B3D6D351A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3207D8E7-36E3-4714-9B03-7B5B3D6D351A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3207D8E7-36E3-4714-9B03-7B5B3D6D351A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -107,6 +113,7 @@ Global {44982F9B-6116-44E2-85D0-F39650B1EF99} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} {3DCD6D1A-C830-4241-B7E4-27430E7EA483} = {F98C0329-C004-417F-B2AB-7466E88D8220} {991D0231-4623-496D-8BD0-9CA906029CBC} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} + {3207D8E7-36E3-4714-9B03-7B5B3D6D351A} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286} diff --git a/Modules.Logging.Test/ConstructorUnitTest.vb b/Modules.Logging.Test/ConstructorUnitTest.vb new file mode 100644 index 00000000..f8b7bbe7 --- /dev/null +++ b/Modules.Logging.Test/ConstructorUnitTest.vb @@ -0,0 +1,52 @@ +Imports System.Text +Imports System.IO +Imports Microsoft.VisualStudio.TestTools.UnitTesting +Imports DigitalData.Modules.Logging + +''' +''' Test creating the log path in various configurations +''' + Public Class ConstructorUnitTest + Private Shared _currentDirectoryLogPath = Path.Combine(Directory.GetCurrentDirectory(), "Log") + Private Shared _appdataDirectoryLogPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Digital Data", "Modules.Logging") + Private Shared _customDirectoryLogPath = Path.Combine(Directory.GetCurrentDirectory(), "CustomLogFolder") + Private Shared _restrictedDirectoryLogPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "ShouldNotBeCreated") + Private Shared _nonsenseDirectoryLogPath = "X:\FOO\BAR\BAZ\QUUX" + + Public Sub TestConstructorCurrentDirectory() + Dim oLogConfig As New LogConfig(LogConfig.PathType.CurrentDirectory) + + Assert.AreEqual(_currentDirectoryLogPath, oLogConfig.LogDirectory) + End Sub + + Public Sub TestConstructorApplicationDirectory() + Dim oLogConfig As New LogConfig(LogConfig.PathType.AppData) + + Assert.AreEqual(_appdataDirectoryLogPath, oLogConfig.LogDirectory) + End Sub + + Public Sub TestConstructorCustomDirectory() + Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath, _customDirectoryLogPath) + + Assert.AreEqual(_customDirectoryLogPath, oLogConfig.LogDirectory) + End Sub + + Public Sub TestConstructorRestrictedDirectory() + Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath, _restrictedDirectoryLogPath) + + Assert.AreEqual(Path.GetTempPath, oLogConfig.LogDirectory) + End Sub + + Public Sub TestConstructorNonsenseDirectory() + Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath, _nonsenseDirectoryLogPath) + + Assert.AreEqual(Path.GetTempPath, oLogConfig.LogDirectory) + End Sub + + Public Shared Sub Cleanup() + Directory.Delete(_currentDirectoryLogPath, True) + Directory.Delete(_appdataDirectoryLogPath, True) + Directory.Delete(_customDirectoryLogPath, True) + End Sub + +End Class \ No newline at end of file diff --git a/Modules.Logging.Test/Logging.Test.vbproj b/Modules.Logging.Test/Logging.Test.vbproj new file mode 100644 index 00000000..98ef1481 --- /dev/null +++ b/Modules.Logging.Test/Logging.Test.vbproj @@ -0,0 +1,133 @@ + + + + + Debug + AnyCPU + {3207D8E7-36E3-4714-9B03-7B5B3D6D351A} + Library + DigitalData.Modules.Logging.Test + DigitalData.Modules.Logging.Test + 512 + Windows + v4.6.1 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + true + true + bin\Debug\ + DigitalData.Modules.Logging.Test.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + DigitalData.Modules.Logging.Test.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + ..\packages\MSTest.TestFramework.1.2.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.2.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + {903b2d7d-3b80-4be9-8713-7447b704e1b0} + Logging + + + + + + + Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}". + + + + + + \ No newline at end of file diff --git a/Modules.Logging.Test/My Project/Application.Designer.vb b/Modules.Logging.Test/My Project/Application.Designer.vb new file mode 100644 index 00000000..8ab460ba --- /dev/null +++ b/Modules.Logging.Test/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Modules.Logging.Test/My Project/Application.myapp b/Modules.Logging.Test/My Project/Application.myapp new file mode 100644 index 00000000..758895de --- /dev/null +++ b/Modules.Logging.Test/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Modules.Logging.Test/My Project/AssemblyInfo.vb b/Modules.Logging.Test/My Project/AssemblyInfo.vb new file mode 100644 index 00000000..c26126de --- /dev/null +++ b/Modules.Logging.Test/My Project/AssemblyInfo.vb @@ -0,0 +1,18 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + + + + + + + + + + + + +' + + diff --git a/Modules.Logging.Test/My Project/Resources.Designer.vb b/Modules.Logging.Test/My Project/Resources.Designer.vb new file mode 100644 index 00000000..49091756 --- /dev/null +++ b/Modules.Logging.Test/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + '-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + 'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + 'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + ''' + ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("DigitalData.Modules.Logging.Test.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + ''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Modules.Logging.Test/My Project/Resources.resx b/Modules.Logging.Test/My Project/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/Modules.Logging.Test/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Modules.Logging.Test/My Project/Settings.Designer.vb b/Modules.Logging.Test/My Project/Settings.Designer.vb new file mode 100644 index 00000000..80ff0bac --- /dev/null +++ b/Modules.Logging.Test/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "Automatische My.Settings-Speicherfunktion" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.DigitalData.Modules.Logging.Test.My.MySettings + Get + Return Global.DigitalData.Modules.Logging.Test.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Modules.Logging.Test/My Project/Settings.settings b/Modules.Logging.Test/My Project/Settings.settings new file mode 100644 index 00000000..85b890b3 --- /dev/null +++ b/Modules.Logging.Test/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Modules.Logging.Test/packages.config b/Modules.Logging.Test/packages.config new file mode 100644 index 00000000..09089438 --- /dev/null +++ b/Modules.Logging.Test/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file