using GBDD;
using Xunit;

namespace GBDD.Tests;

public class SqlQueriesTests
{
    [Fact]
    public void AuthorizationUser_ReturnsExpectedSql()
    {
        string sql = SqlQueries.AuthorizationUser("admin", "12345");

        Assert.Equal("select authorization_user('admin', '12345')", sql);
    }

    [Fact]
    public void DriverIdByLogin_ReturnsExpectedSql()
    {
        string sql = SqlQueries.DriverIdByLogin("driver@mail.ru");

        Assert.Equal("select driver_id from app_user where login = 'driver@mail.ru'", sql);
    }

    [Fact]
    public void AddDriver_IncludesAllDriverFields()
    {
        string sql = SqlQueries.AddDriver(
            "Иванов",
            "Иван",
            "Иванович",
            "2000-01-15",
            "Казань",
            "Пушкина",
            "10",
            "5",
            "420000");

        Assert.Contains("select add_driver(", sql);
        Assert.Contains("'Иванов'", sql);
        Assert.Contains("'Иван'", sql);
        Assert.Contains("'2000-01-15'", sql);
        Assert.Contains("'420000'", sql);
    }

    [Fact]
    public void AddViolation_IncludesDriverVehicleTypeUinAndAmount()
    {
        string sql = SqlQueries.AddViolation(7, 12, 3, "18810116240101000001", "1500");

        Assert.Contains("select add_violation(", sql);
        Assert.Contains("7", sql);
        Assert.Contains("12", sql);
        Assert.Contains("3", sql);
        Assert.Contains("current_date", sql);
        Assert.Contains("'18810116240101000001'", sql);
        Assert.Contains("1500", sql);
    }
}
