forked from JSONAPIdotNET/JSONAPI.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestHelpers.cs
More file actions
29 lines (27 loc) · 995 Bytes
/
Copy pathTestHelpers.cs
File metadata and controls
29 lines (27 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Data.Common;
using System.IO;
using System.Reflection;
using Effort;
using Effort.DataLoaders;
namespace JSONAPI.EntityFramework.Tests
{
internal static class TestHelpers
{
public static string ReadEmbeddedFile(string path)
{
var resourcePath = "JSONAPI.EntityFramework.Tests." + path.Replace("\\", ".").Replace("/", ".");
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourcePath))
{
if (stream == null) throw new Exception("Could not find a file at the path: " + path);
return new StreamReader(stream).ReadToEnd();
}
}
public static DbConnection GetEffortConnection(string relativeDataPath)
{
var dataPath = Path.GetFullPath(relativeDataPath);
var dataLoader = new CsvDataLoader(dataPath);
return DbConnectionFactory.CreateTransient(dataLoader);
}
}
}