How to use RavenDB.RavenTestDriver 5+ without .NET 5 in my unit tests project?

356 Views Asked by At

When running RavenDB Test driver 5.0+ i'm getting an exception that ASP.NET Core 5.0.0 is required.

Sstem.InvalidOperationException: Unable to start the RavenDB Server
It was not possible to find any compatible framework version
The framework 'Microsoft.AspNetCore.App', version '5.0.0' was not found.
  - The following frameworks were found:
      2.1.23 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      3.1.9 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]

How can i use it without migrating my project to .NET 5.0?

1

There are 1 best solutions below

0
On BEST ANSWER

Yes, it's possible to use RavenDB 5 without ASP.NET/.NET 5.

You need to explicitly specify the version during configuration, or simply set it to null:

var ravenServerOptions = new TestServerOptions()
{
    FrameworkVersion = null
};

ConfigureServer(ravenServerOptions);

For example using NUnit:

[TestFixture]
public class FooTest : RavenTestDriver
{
    private IDocumentStore store;

    [OneTimeSetUp]
    public void OneTimeSetUp()
    {
        var ravenServerOptions = new TestServerOptions()
        {
            FrameworkVersion = null
        };

        ConfigureServer(ravenServerOptions);

        store = GetDocumentStore();
    }

    [OneTimeTearDown]
    public void OneTimeTearDown()
    {
        store.Dispose();
    }

    [Test]
    public void Test()
    {

    }
}