# Tests block

variables:
  NUNIT_VERSION: '3.12.0'
  nuget: 'C:/GitLab-Runner/Programs/nuget.exe'
  msbuild: 'D:/Program Files/Visual Studio/Cummunity/MSBuild/Current/Bin/MSBuild.exe'

# Nunit preparation template for running tests
.before_nunit_install: &nunit_install
  before_script:
    - CHCP 65001
    - '& "$env:nuget" restore'
    - '& "$env:nuget" install NUnit.ConsoleRunner -o tmp/nunit -version "$env:NUNIT_VERSION"'
    - 'cp -r tmp/nunit/NUnit.ConsoleRunner.$NUNIT_VERSION/tools/ nunit/'

# Tests reports generate and attach to gitlab 
.junit_reports_generate: &junit_reports_generate
  after_script:
    - '$xml = Resolve-Path TestResult.xml'

    - '$output = Join-Path ($pwd) junit-results.xml'

    - '$template = Resolve-Path ci/nunit3-junit.xslt'

    - '$xslt = New-Object System.Xml.Xsl.XslCompiledTransform;'
    - '$xslt.Load($template);'
    - '$xslt.Transform($xml, $output);'
  artifacts:
    when: always
    reports:
      junit:
        - junit-results.xml

# Isolated tests extend
.isolated_tests_extend:
  stage: test
  tags:
    - msbuild
  <<: *nunit_install
  <<: *junit_reports_generate
  script:
    - 'nunit/nunit3-console.exe _unitTests/UnitTests.dll --result=TestResult.xml'
