|
|
@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
using DbContextLib;
|
|
|
|
|
|
|
|
using DbDataManager.Service;
|
|
|
|
|
|
|
|
using Entities;
|
|
|
|
|
|
|
|
using Microsoft.Data.Sqlite;
|
|
|
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
using Model.OrderCriteria;
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
using API.Service;
|
|
|
|
|
|
|
|
using Model;
|
|
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
using StubbedContextLib;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace TestAPI.ServiceAPI
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public class UnitTestQueryDataServiceApi
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
private readonly StubbedContext _dbContext;
|
|
|
|
|
|
|
|
private readonly QueryDataServiceApi _queryService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UnitTestQueryDataServiceApi()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var connection = new SqliteConnection("DataSource=:memory:");
|
|
|
|
|
|
|
|
connection.Open();
|
|
|
|
|
|
|
|
var options = new DbContextOptionsBuilder<UserDbContext>()
|
|
|
|
|
|
|
|
.UseSqlite(connection)
|
|
|
|
|
|
|
|
.Options;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_dbContext = new StubbedContext(options);
|
|
|
|
|
|
|
|
_queryService = new QueryDataServiceApi();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void ExecuteQuery_Success_When_Select_Users()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var jsonResult = _queryService.ExecuteQuery("Select * from \"User\";", "SQLuedo");
|
|
|
|
|
|
|
|
var result = JsonConvert.DeserializeObject<User[]>(jsonResult.Result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(result);
|
|
|
|
|
|
|
|
Assert.Equal(11, result.Count());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|