Using the constructor TestDatabaseSetup(Assembly baseAssembly, Assembly[] mappingAssemblies) of TestDatabaseSetup class will fail under Unix-based systems, because UriBuilder can't handle paths which start with slash (\ or /).
E.g.:
/absolute/path/on/linux
\relative\path\on\Windows
(CodeBaseLocator.GetAssemblyCodeBasePath uses the UriBuilder class.)
See "Implicit File Path Support" part of Uri Class documentation on why using this class on Unix-based system is problematic.
Stacktrace
---- System.UriFormatException : Invalid URI: The hostname could not be parsed.
Stack Trace:
----- Inner Stack Trace #1 (System.UriFormatException) -----
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString)
at System.UriBuilder..ctor(String uri)
at SharpArch.Infrastructure.CodeBaseLocator.GetAssemblyCodeBasePath(Assembly assembly)
at SharpArch.Testing.NHibernate.TestDatabaseSetup..ctor(Assembly baseAssembly, Assembly[] mappingAssemblies)
using System;
using SharpArch.Testing.NHibernate;
using Xunit;
namespace SharpArchBug
{
public class BugTest : TestDatabaseSetup
{
public BugTest() : base(typeof(BugTest).Assembly, new[] {typeof(BugTest).Assembly})
{
}
[Fact]
public void Will_Not_Reach_This_On_Linux()
{
Assert.False(false);
}
}
}
Problem
Using the constructor
TestDatabaseSetup(Assembly baseAssembly, Assembly[] mappingAssemblies)
ofTestDatabaseSetup
class will fail under Unix-based systems, becauseUriBuilder
can't handle paths which start with slash (\
or/
). E.g.:(
CodeBaseLocator.GetAssemblyCodeBasePath
uses theUriBuilder
class.)See "Implicit File Path Support" part of Uri Class documentation on why using this class on Unix-based system is problematic.
Stacktrace
Used
.Net (5.0) SharpArch.Testing.Xunit.NHibernate (7.0.0) Xunit (2.4.1) Microsoft.NET.Test.Sdk (16.11.0)
Steps to reproduce