Imports System.IO
Imports FluentAssertions
'''
''' Test creating the log path in various configurations
'''
Public Class ConstructorUnitTest
Private Shared ReadOnly _currentDirectoryLogPath = Path.Combine(Directory.GetCurrentDirectory(), "Log")
Private Shared ReadOnly _appdataDirectoryLogPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Digital Data", "Modules.Logging.Test", "Log")
Private Shared ReadOnly _customDirectoryLogPath = Path.Combine(Directory.GetCurrentDirectory(), "CustomLogFolder")
Private Shared ReadOnly _restrictedDirectoryLogPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "ShouldNotBeCreated")
Private Shared ReadOnly _nonsenseDirectoryLogPath = "X:\DOES\NOT\EVER\EXIST"
Public Sub TestConstructorCurrentDirectory()
Dim oLogConfig As New LogConfig(LogConfig.PathType.Temp)
Dim oTempPath = Path.GetTempPath
oLogConfig.LogDirectory.Should.Be(oTempPath)
End Sub
Public Sub TestConstructorApplicationDirectory()
Dim oLogConfig As New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing, "Digital Data", "Modules.Logging")
oLogConfig.LogDirectory.Should.Be(_appdataDirectoryLogPath)
End Sub
Public Sub TestConstructorCustomDirectory()
Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath, _customDirectoryLogPath)
oLogConfig.LogDirectory.Should.Be(_customDirectoryLogPath)
End Sub
Public Sub TestConstructorRestrictedDirectory()
Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath, _restrictedDirectoryLogPath)
Dim oTempPath = Path.GetTempPath
oLogConfig.LogDirectory.Should.Be(oTempPath)
End Sub
Public Sub TestConstructorNonsenseDirectory()
Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath, _nonsenseDirectoryLogPath)
Dim oTempPath = Path.GetTempPath
oLogConfig.LogDirectory.Should.Be(oTempPath)
End Sub
Public Shared Sub Cleanup()
Directory.Delete(_currentDirectoryLogPath, True)
Directory.Delete(_appdataDirectoryLogPath, True)
Directory.Delete(_customDirectoryLogPath, True)
End Sub
End Class