Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestDatabaseSetup constructor fails under Linux #250

Closed
annamaria-szentpeteri opened this issue Sep 6, 2021 · 0 comments
Closed

TestDatabaseSetup constructor fails under Linux #250

annamaria-szentpeteri opened this issue Sep 6, 2021 · 0 comments
Assignees
Labels
Milestone

Comments

@annamaria-szentpeteri
Copy link

Problem

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)

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

  1. Create new UnitTest project under .Net5.
  2. Install NuGet packages mentioned above.
  3. Use this test class to reproduce problem:
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);
        }
    }
}

  1. Run unittests under Unix-based system.
@cd21h cd21h self-assigned this Sep 7, 2021
@cd21h cd21h added this to the 7.1.0 milestone Oct 9, 2021
@cd21h cd21h closed this as completed Oct 12, 2021
cd21h added a commit that referenced this issue Oct 25, 2021
* Move assembly parameters to Directory.Build.props, closes #257
* Fix GetAssemblyCodeBasePath() for Linux deployments, closes #250
@cd21h cd21h added the bug label Oct 27, 2021
cd21h added a commit that referenced this issue Oct 27, 2021
* Move assembly parameters to Directory.Build.props, closes #257
* Fix GetAssemblyCodeBasePath() for Linux deployments, closes #250
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants