namespace ZB.MOM.WW.LmxProxy.Client.IntegrationTests;

public class ReadTests : IntegrationTestBase
{
    [Fact]
    public async Task Read_BoolTag_ReturnsBoolValue()
    {
        var vtq = await Client!.ReadAsync("TestChildObject.TestBool");
        Assert.IsType<bool>(vtq.Value);
        Assert.True(vtq.Quality.IsGood());
    }

    [Fact]
    public async Task Read_IntTag_ReturnsIntValue()
    {
        var vtq = await Client!.ReadAsync("TestChildObject.TestInt");
        Assert.True(vtq.Value is int or long);
        Assert.True(vtq.Quality.IsGood());
    }

    [Fact]
    public async Task Read_FloatTag_ReturnsFloatValue()
    {
        var vtq = await Client!.ReadAsync("TestChildObject.TestFloat");
        Assert.True(vtq.Value is float or double);
        Assert.True(vtq.Quality.IsGood());
    }

    [Fact]
    public async Task Read_DoubleTag_ReturnsDoubleValue()
    {
        var vtq = await Client!.ReadAsync("TestChildObject.TestDouble");
        Assert.IsType<double>(vtq.Value);
        Assert.True(vtq.Quality.IsGood());
    }

    [Fact]
    public async Task Read_StringTag_ReturnsStringValue()
    {
        var vtq = await Client!.ReadAsync("TestChildObject.TestString");
        Assert.IsType<string>(vtq.Value);
        Assert.True(vtq.Quality.IsGood());
    }

    [Fact]
    public async Task Read_DateTimeTag_ReturnsDateTimeValue()
    {
        var vtq = await Client!.ReadAsync("TestChildObject.TestDateTime");
        Assert.IsType<DateTime>(vtq.Value);
        Assert.True(vtq.Quality.IsGood());
        Assert.True(DateTime.UtcNow - vtq.Timestamp < TimeSpan.FromHours(1));
    }

    [Fact]
    public async Task ReadBatch_MultipleTags_ReturnsDictionary()
    {
        var tags = new[] { "TestChildObject.TestString", "TestChildObject.TestInt" };
        var results = await Client!.ReadBatchAsync(tags);
        Assert.Equal(2, results.Count);
    }
}
