steps:
- task: DownloadBuildArtifacts@0
  inputs:
    artifactName: imobiledevice-net

- script: |
    unzip $SYSTEM_ARTIFACTSDIRECTORY/imobiledevice-net/iMobileDevice-net.*.nupkg -d $BUILD_SOURCESDIRECTORY/zip
    ls -l $BUILD_SOURCESDIRECTORY/zip/runtimes/$RID/native
    export LD_LIBRARY_PATH=$BUILD_SOURCESDIRECTORY/zip/runtimes/$RID/native:$LD_LIBRARY_PATH
    dotnet test iMobileDevice.Generator.Tests/iMobileDevice.Generator.Tests.csproj
    dotnet test iMobileDevice.Tests/iMobileDevice.Tests.csproj
  displayName: Run unit tests

- script: |
    chmod +x $BUILD_SOURCESDIRECTORY/zip/runtimes/$RID/native/iproxy
    chmod +x $BUILD_SOURCESDIRECTORY/zip/runtimes/$RID/native/idevice_id
    $BUILD_SOURCESDIRECTORY/zip/runtimes/$RID/native/iproxy --help
    $BUILD_SOURCESDIRECTORY/zip/runtimes/$RID/native/idevice_id --help
  displayName: Test utilities

- script: |
    mkdir packages
    cp $SYSTEM_ARTIFACTSDIRECTORY/imobiledevice-net/*.nupkg packages/
    cp $SYSTEM_ARTIFACTSDIRECTORY/imobiledevice-net/*.props iMobileDevice.IntegrationTest.netcoreapp20/
    ls packages/

    cd iMobileDevice.IntegrationTest.netcoreapp20
    dotnet run
  displayName: Run integration tests
steps:
- task: DownloadBuildArtifacts@0
  inputs:
    artifactName: imobiledevice-net

- script: |
    unzip $SYSTEM_ARTIFACTSDIRECTORY/imobiledevice-net/iMobileDevice-net.*.nupkg -d $BUILD_SOURCESDIRECTORY/zip
    ls -l $BUILD_SOURCESDIRECTORY/zip/runtimes/$RID/native

- script: |
    chmod +x $BUILD_SOURCESDIRECTORY/zip/runtimes/$RID/native/iproxy
    chmod +x $BUILD_SOURCESDIRECTORY/zip/runtimes/$RID/native/idevice_id
    $BUILD_SOURCESDIRECTORY/zip/runtimes/$RID/native/iproxy --help
    $BUILD_SOURCESDIRECTORY/zip/runtimes/$RID/native/idevice_id --help
  displayName: Test utilities

- script: |
    export LD_LIBRARY_PATH=$BUILD_SOURCESDIRECTORY/zip/runtimes/$RID/native:$LD_LIBRARY_PATH
    dotnet test iMobileDevice.Generator.Tests/iMobileDevice.Generator.Tests.csproj
    dotnet test iMobileDevice.Tests/iMobileDevice.Tests.csproj
  displayName: Run unit tests

- script: |
    mkdir packages
    cp $SYSTEM_ARTIFACTSDIRECTORY/imobiledevice-net/*.nupkg packages/
    cp $SYSTEM_ARTIFACTSDIRECTORY/imobiledevice-net/*.props iMobileDevice.IntegrationTest.netcoreapp20/
    ls packages/

    cd iMobileDevice.IntegrationTest.netcoreapp20
    dotnet run
  displayName: Run integration tests
Test utilities before running unit tests
Test utilities before running unit tests
