# appveyor file
# http://www.appveyor.com/docs/appveyor-yml

init:
  - git config --global core.autocrlf input

configuration: Release

# what combinations to test
environment:
  COVERALLS_REPO_TOKEN:
    secure: cQNk8AJNS170fAjFz49c4KPd3F7pnlpgXVhQNBle8gdz6KdsSVxxi/EyQkXTGYvW
  matrix:
    - nodejs_version: 0.10

install:
  - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
  - npm install -g grunt-cli
  - npm install

build_script:
  - node --version
  - npm --version
  - ps: >-
      $testConfig = @'

      <?xml version="1.0" encoding="utf-8" ?>
      <configuration>
        <appSettings>
          <add key="UATestEndpoint" value="opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"/>
        </appSettings>
      </configuration>

      '@

      $testConfig | Out-File "tests\App.config" -Encoding ascii
  - grunt build --no-color


test: off # tests are done in the build script

notifications:
  - provider: Slack
    auth_token:
      secure: kZJj/SgQfdjaIEQXm6VjBl82Va3Hts5kn/qMoj19w36m5EbGoR+vjabZAq7xS2Mj
    channel: github

test_script:
- ps: >-
    choco install opc-components -version 106.0.201.2

    choco install grayboxsimulator -version 1.8.0.2

    packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -register:user "-target:"".\packages\NUnit.ConsoleRunner.3.4.1\tools\nunit3-console.exe""" "-targetargs:""tests\bin\$env:CONFIGURATION\tests.dll"" --x86" -output:opencoverCoverage.xml

    $coveralls = (Resolve-Path "./packages/coveralls.net.*/tools/csmacnz.coveralls.exe").ToString()

    $env:APPVEYOR_BUILD_NUMBER

    #.\packages\coveralls.net.0.6.0\tools\csmacnz.Coveralls.exe --opencover -i opencoverCoverage.xml --repoToken $env:COVERALLS_REPO_TOKEN --useRelativePaths --commitId $env:APPVEYOR_REPO_COMMIT --commitBranch $env:APPVEYOR_REPO_BRANCH --commitAuthor $env:APPVEYOR_REPO_COMMIT_AUTHOR --commitEmail $env:APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL --commitMessage $env:APPVEYOR_REPO_COMMIT_MESSAGE --jobId $env:APPVEYOR_BUILD_NUMBER --serviceName appveyor