Is it possible to create an In-memory database using SQLite.Net-PCL?

I am currently working on unit tests for the Xamarin MvvmCross application using SQLite.Net-PCL 3.1.1. The unit test project is a regular .NET project.

So now I'm mocking MvxSqliteConnectionFactoryBase

public class MockMvxSqliteConnectionFactoryBase :  MvxSqliteConnectionFactoryBase
{
    #region implemented abstract members of MvxSqliteConnectionFactoryBase

    public override string GetPlattformDatabasePath(string databaseName)
    {
        return "Data Source=:memory:";
    }

    public override ISQLitePlatform GetCurrentPlatform()
    {
        return new SQLite.Net.Platform.Generic.SQLitePlatformGeneric(); 
    }
    public override ISQLitePlatform GetCurrentPlatform(string key)
    {
        return new  SQLite.Net.Platform.Generic.SQLitePlatformGeneric();
    }

    #endregion
}

But the database is not created in memory, not in the binproject folder .

I tried to initialize SQLiteConnectionas follows, but there is no constructor that accepts only one line.

+4
source share
1 answer

Following the prompt that @CL. gave me, I changed the GetPlattformDatabasePath method:

public override string GetPlattformDatabasePath(string databaseName)
    {
        return ":memory:";
    }

, - bin, , unit test, .

+1

All Articles