#!/usr/bin/env bash

set -eo pipefail
source debian/tests/.tests.rc.d/init.sh

function CheckForPresenceOfEssentialDotnetBinaries
{
    LogInfo "Check if '/usr/bin/dotnet' is present."
    test -e "/usr/bin/dotnet"

    LogInfo "Check if '/usr/lib/dotnet/dotnet' is present."
    test -e "/usr/lib/dotnet/dotnet"

    LogInfo "Check if '/usr/bin/dotnet' points to '/usr/lib/dotnet/dotnet'."
    test "$(readlink -f /usr/bin/dotnet)" = "/usr/lib/dotnet/dotnet"

    LogInfo "Check if '/usr/lib/dotnet/sdk/$DOTNET_SDK_VERSION' folder is present."
    test -d "/usr/lib/dotnet/sdk/$DOTNET_SDK_VERSION"
}

function CheckForPresenceOfEssentialDotnetConfigFiles
{
    LogInfo "Check if '/etc/dotnet/install_location' is present."
    test -e "/etc/dotnet/install_location"

    LogInfo "Check if '/etc/profile.d/dotnet.sh' is present."
    test -e "/etc/profile.d/dotnet.sh"
}

CheckForPresenceOfEssentialDotnetBinaries
CheckForPresenceOfEssentialDotnetConfigFiles

LogInfo "Test Ok!"
