Fix filesystem refs

This commit is contained in:
Jonathan Jenne
2023-09-05 10:47:37 +02:00
parent af90bb9efe
commit 6f33261101
25 changed files with 132 additions and 1527 deletions

View File

@@ -1,46 +1,46 @@
Imports System.Text
Imports System.IO
Imports Microsoft.VisualStudio.TestTools.UnitTesting
Imports DigitalData.Modules.Logging
Imports System.IO
Imports FluentAssertions
''' <summary>
''' Test creating the log path in various configurations
''' </summary>
<TestClass()> 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", "Log")
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"
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()
Assert.ThrowsException(Of ArgumentException)(Sub()
Dim oLogConfig As New LogConfig(LogConfig.PathType.Temp)
End Sub)
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")
Assert.AreEqual(_appdataDirectoryLogPath, oLogConfig.LogDirectory)
oLogConfig.LogDirectory.Should.Be(_appdataDirectoryLogPath)
End Sub
<TestMethod()> Public Sub TestConstructorCustomDirectory()
Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath, _customDirectoryLogPath)
Assert.AreEqual(_customDirectoryLogPath, oLogConfig.LogDirectory)
oLogConfig.LogDirectory.Should.Be(_customDirectoryLogPath)
End Sub
<TestMethod()> Public Sub TestConstructorRestrictedDirectory()
Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath, _restrictedDirectoryLogPath)
Dim oTempPath = Path.GetTempPath
Assert.AreEqual(Path.GetTempPath, oLogConfig.LogDirectory)
oLogConfig.LogDirectory.Should.Be(oTempPath)
End Sub
<TestMethod()> Public Sub TestConstructorNonsenseDirectory()
Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath, _nonsenseDirectoryLogPath)
Dim oTempPath = Path.GetTempPath
Assert.AreEqual(Path.GetTempPath, oLogConfig.LogDirectory)
oLogConfig.LogDirectory.Should.Be(oTempPath)
End Sub
<ClassCleanup()> Public Shared Sub Cleanup()

View File

@@ -52,6 +52,9 @@
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentAssertions, Version=6.12.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.6.12.0\lib\netstandard2.0\FluentAssertions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
@@ -60,6 +63,12 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.0\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />

View File

@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="6.12.0" targetFramework="net462" />
<package id="MSTest.TestAdapter" version="2.1.2" targetFramework="net461" />
<package id="MSTest.TestFramework" version="2.1.2" targetFramework="net461" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.0" targetFramework="net462" />
<package id="System.Threading.Tasks.Extensions" version="4.5.0" targetFramework="net462" />
</packages>