Imports System.IO
Imports FluentAssertions

''' <summary>
''' Test creating the log path in various configurations
''' </summary>
<TestClass()> 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"

    <TestMethod()> Public Sub TestConstructorCurrentDirectory()
        Dim oLogConfig As New LogConfig(LogConfig.PathType.Temp)
        Dim oTempPath = Path.GetTempPath
        oLogConfig.LogDirectory.Should.Be(oTempPath)
    End Sub

    <TestMethod()> Public Sub TestConstructorApplicationDirectory()
        Dim oLogConfig As New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing, "Digital Data", "Modules.Logging")

        oLogConfig.LogDirectory.Should.Be(_appdataDirectoryLogPath)
    End Sub

    <TestMethod()> Public Sub TestConstructorCustomDirectory()
        Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath, _customDirectoryLogPath)

        oLogConfig.LogDirectory.Should.Be(_customDirectoryLogPath)
    End Sub

    <TestMethod()> Public Sub TestConstructorRestrictedDirectory()
        Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath, _restrictedDirectoryLogPath)
        Dim oTempPath = Path.GetTempPath

        oLogConfig.LogDirectory.Should.Be(oTempPath)
    End Sub

    <TestMethod()> Public Sub TestConstructorNonsenseDirectory()
        Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath, _nonsenseDirectoryLogPath)
        Dim oTempPath = Path.GetTempPath

        oLogConfig.LogDirectory.Should.Be(oTempPath)
    End Sub

    <ClassCleanup()> Public Shared Sub Cleanup()
        Directory.Delete(_currentDirectoryLogPath, True)
        Directory.Delete(_appdataDirectoryLogPath, True)
        Directory.Delete(_customDirectoryLogPath, True)
    End Sub

End Class