You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
EntityFrameworkCore.Jet/test/EFCore.Jet.FunctionalTests/AssertSqlHelper.cs

52 lines
1.5 KiB
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.TestUtilities;
static internal class AssertSqlHelper
{
public static void AssertSql(this TestSqlLoggerFactory testSqlLoggerFactory, params string[] expected)
{
string[] expectedFixed = new string[expected.Length];
int i = 0;
foreach (var item in expected)
{
if (IgnoreStatement(item))
return;
expectedFixed[i++] = item.Replace("\r\n", "\n");
}
testSqlLoggerFactory.AssertBaseline(expectedFixed);
}
public static void AssertContains(this TestSqlLoggerFactory testSqlLoggerFactory, params string[] expected)
{
string[] expectedFixed = new string[expected.Length];
int i = 0;
foreach (var item in expected)
{
expectedFixed[i++] = item.Replace("\r\n", "\n");
}
testSqlLoggerFactory.AssertBaseline(expectedFixed, assertOrder: false);
}
public static bool IgnoreStatement(string item)
{
if (item.Contains("CAST"))
return true;
if (item.Contains("COALESCE"))
return true;
if (item.Contains("CONVERT"))
return true;
if (item.Contains("WHEN"))
return true;
if (item.Contains("LEFT JOIN"))
return true;
if (item.Contains("INNER JOIN"))
return true;
if (item.Contains("CROSS JOIN"))
return true;
if (item.Contains("CHARINDEX"))
return true;
return false;
}
}