forked from DynamicsValue/fake-xrm-easy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-assemblies.ps1
60 lines (45 loc) · 1.97 KB
/
test-assemblies.ps1
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
55
param (
[string]$targetFrameworks = "all",
[string]$configuration = "FAKE_XRM_EASY_9"
)
function Test-OneAssemblyAtPath
{
param (
[string]$assemblyPath,
[string]$assemblyName
)
$dirSeparator = [IO.Path]::DirectorySeparatorChar
Write-Host " -> Preparing tests for $($assemblyName)..." -ForegroundColor Yellow
Write-Host "Checking if runtime config exists at $($assemblyPath)..." -ForegroundColor Yellow
$packageRuntimeConfigPath = "$($assemblyPath)/$($assemblyName).runtimeconfig.json"
$runtimeConfigPath = "$($assemblyPath)/FakeXrmEasy.Tests.runtimeconfig.json"
$packageRuntimeConfigExists = Test-Path $packageRuntimeConfigPath -PathType leaf
$runtimeConfigExists = Test-Path $runtimeConfigPath -PathType leaf
if($runtimeConfigExists -And !($packageRuntimeConfigExists))
{
Write-Host " -> Copying runtime config at $($runtimeConfigPath) to $($packageRuntimeConfigPath) ..." -ForegroundColor Yellow
Copy-Item $runtimeConfigPath -Destination $packageRuntimeConfigPath
}
Write-Host " -> Running tests for $($assemblyName)..." -ForegroundColor Yellow
dotnet test "$($assemblyPath)$($dirSeparator)$($assemblyName).dll"
}
function Test-AssembliesAtPath
{
param (
[string]$assemblyPath
)
Test-OneAssemblyAtPath -assemblyPath $assemblyPath -assemblyName "FakeXrmEasy.Abstractions.Tests"
Test-OneAssemblyAtPath -assemblyPath $assemblyPath -assemblyName "FakeXrmEasy.Core.Tests"
Test-OneAssemblyAtPath -assemblyPath $assemblyPath -assemblyName "FakeXrmEasy.Messages.Tests"
Test-OneAssemblyAtPath -assemblyPath $assemblyPath -assemblyName "FakeXrmEasy.Plugins.Tests"
}
$targetPath = "tests/FakeXrmEasy.Tests/bin/$($configuration)/$($targetFrameworks)"
if($targetFrameworks -eq "all")
{
$targetPath = "tests/FakeXrmEasy.Tests/bin/$($configuration)/net6.0"
Test-AssembliesAtPath -assemblyPath $targetPath
}
else
{
Test-AssembliesAtPath -assemblyPath $targetPath
}