I have recently built a quiz application for Xamarin.Android, and want to dome some Unit Testing on the shared library.
I am using a repository pattern with the following files.
SQLiteMyAppRepository.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SQLite;
namespace MyApp.DataLayer
{
public class MyAppRepository : IMyAppRepository
{
public static string DatabaseName = "MyApp.sqlite";
private SQLiteConnection _dbConnection;
public MyAppRepository()
{
string docFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string dbFilePath = Path.Combine(docFolder, DatabaseName);
_dbConnection = new SQLiteConnection(dbFilePath);
}
I have then created a new project to test some of these elements.
The primary issue I am having, is that when I try and run the test, I am getting the following exception:
MyApp.Tests.RepositoryTests.AddQuestion threw
exception:
SQLite.SQLiteException: no such table: Questions
I have been messing about with it for a few hours now and can't seem to find what is wrong, any help would be appreciated. I thought Mocking the repository would get around any issues like this.