-
-
Notifications
You must be signed in to change notification settings - Fork 512
/
Copy pathInfrastructureTests.cs
54 lines (45 loc) · 1.58 KB
/
InfrastructureTests.cs
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Linq;
using SqlKata.Compilers;
using SqlKata.Tests.Infrastructure;
using Xunit;
namespace SqlKata.Tests
{
public class InfrastructureTests : TestSupport
{
[Fact]
public void CanGetCompiler()
{
var compiler = Compilers.Get(EngineCodes.SqlServer);
Assert.NotNull(compiler);
Assert.IsType<SqlServerCompiler>(compiler);
}
[Fact]
public void CanCompile()
{
var results = Compilers.Compile(new Query("Table"));
Assert.NotNull(results);
Assert.Equal(Compilers.KnownEngineCodes.Count(), results.Count);
}
[Fact]
public void CanCompileSelectively()
{
var desiredEngines = new[] { EngineCodes.SqlServer, EngineCodes.MySql };
var results = Compilers.Compile(desiredEngines, new Query("Table"));
Assert.Equal(desiredEngines.Length, results.Count);
Assert.Contains(results, a => a.Key == EngineCodes.SqlServer);
Assert.Contains(results, a => a.Key == EngineCodes.MySql);
}
[Fact]
public void ShouldThrowIfInvalidEngineCode()
{
Assert.Throws<InvalidOperationException>(() => Compilers.CompileFor("XYZ", new Query()));
}
[Fact]
public void ShouldThrowIfAnyEngineCodesAreInvalid()
{
var codes = new[] { EngineCodes.SqlServer, "123", EngineCodes.MySql, "abc" };
Assert.Throws<InvalidOperationException>(() => Compilers.Compile(codes, new Query()));
}
}
}