using AyCode.Core.Serializers;
using AyCode.Core.Serializers.Binaries;
using AyCode.Core.Serializers.Jsons;
using AyCode.Core.Tests.TestModels;
using AyCode.Services.SignalRs;

namespace AyCode.Services.Server.Tests.SignalRs.SignalRDatasources;

[TestClass]
public class SignalRDataSourceTests_List_Json : SignalRDataSourceTestBase<TestOrderItemListDataSource, List<TestOrderItem_All_True>>
{
    protected override AcSerializerOptions SerializerOption => new AcJsonSerializerOptions();
    protected override TestOrderItemListDataSource CreateDataSource(TestableSignalRClient2 client, SignalRCrudTags crudTags)
    {
        var ds = new TestOrderItemListDataSource(client, crudTags);
        ds.SerializerType = AcSerializerType.Json;
        return ds;
    }

    [TestMethod]
    public override async Task LoadDataSource_ReturnsAllItems() => await base.LoadDataSource_ReturnsAllItems();
    [TestMethod]
    public override async Task LoadDataSource_ClearsChangeTracking_ByDefault() => await base.LoadDataSource_ClearsChangeTracking_ByDefault();
    [TestMethod]
    public override async Task LoadDataSource_PreservesChangeTracking_WhenFalse() => await base.LoadDataSource_PreservesChangeTracking_WhenFalse();
    [TestMethod]
    public override async Task LoadDataSource_InvokesOnDataSourceLoaded() => await base.LoadDataSource_InvokesOnDataSourceLoaded();
    [TestMethod]
    public override async Task LoadDataSource_MultipleCalls_RefreshesData() => await base.LoadDataSource_MultipleCalls_RefreshesData();
    [TestMethod]
    public override async Task LoadDataSourceAsync_LoadsDataViaCallback() => await base.LoadDataSourceAsync_LoadsDataViaCallback();
    [TestMethod]
    public override async Task LoadItem_ReturnsSingleItem() => await base.LoadItem_ReturnsSingleItem();
    [TestMethod]
    public override async Task LoadItem_AddsToDataSource_WhenNotExists() => await base.LoadItem_AddsToDataSource_WhenNotExists();
    [TestMethod]
    public override async Task LoadItem_UpdatesExisting_WhenAlreadyLoaded() => await base.LoadItem_UpdatesExisting_WhenAlreadyLoaded();
    [TestMethod]
    public override async Task LoadItem_InvokesOnDataSourceItemChanged() => await base.LoadItem_InvokesOnDataSourceItemChanged();
    [TestMethod]
    public override async Task LoadItem_ReturnsNull_WhenNotFound() => await base.LoadItem_ReturnsNull_WhenNotFound();
    [TestMethod]
    public override async Task Add_WithAutoSave_AddsItem() => await base.Add_WithAutoSave_AddsItem();
    [TestMethod]
    public override void Add_WithoutAutoSave_AddsToTrackingOnly() => base.Add_WithoutAutoSave_AddsToTrackingOnly();
    [TestMethod]
    public override void Add_DuplicateId_ThrowsException() => base.Add_DuplicateId_ThrowsException();
    [TestMethod]
    public override void Add_DefaultId_ThrowsException() => base.Add_DefaultId_ThrowsException();
    [TestMethod]
    public override void AddRange_AddsMultipleItems() => base.AddRange_AddsMultipleItems();
    [TestMethod]
    public override async Task AddOrUpdate_AddsNew_WhenNotExists() => await base.AddOrUpdate_AddsNew_WhenNotExists();
    [TestMethod]
    public override async Task AddOrUpdate_UpdatesExisting_WhenExists() => await base.AddOrUpdate_UpdatesExisting_WhenExists();
    [TestMethod]
    public override void Insert_AtIndex_InsertsCorrectly() => base.Insert_AtIndex_InsertsCorrectly();
    [TestMethod]
    public override async Task Insert_WithAutoSave_SavesImmediately() => await base.Insert_WithAutoSave_SavesImmediately();
    [TestMethod]
    public override async Task Update_ByIndex_UpdatesCorrectly() => await base.Update_ByIndex_UpdatesCorrectly();
    [TestMethod]
    public override async Task Update_ByItem_UpdatesCorrectly() => await base.Update_ByItem_UpdatesCorrectly();
    [TestMethod]
    public override void Indexer_Set_TracksUpdate() => base.Indexer_Set_TracksUpdate();
    [TestMethod]
    public override async Task Remove_ById_RemovesItem() => await base.Remove_ById_RemovesItem();
    [TestMethod]
    public override async Task Remove_ByItem_RemovesItem() => await base.Remove_ByItem_RemovesItem();
    [TestMethod]
    public override void Remove_WithoutAutoSave_TracksRemoval() => base.Remove_WithoutAutoSave_TracksRemoval();
    [TestMethod]
    public override void RemoveAt_RemovesCorrectItem() => base.RemoveAt_RemovesCorrectItem();
    [TestMethod]
    public override async Task RemoveAt_WithAutoSave_SavesImmediately() => await base.RemoveAt_WithAutoSave_SavesImmediately();
    [TestMethod]
    public override void TryRemove_ReturnsTrue_WhenExists() => base.TryRemove_ReturnsTrue_WhenExists();
    [TestMethod]
    public override void TryRemove_ReturnsFalse_WhenNotExists() => base.TryRemove_ReturnsFalse_WhenNotExists();
    [TestMethod]
    public override async Task SaveChanges_SavesTrackedItems() => await base.SaveChanges_SavesTrackedItems();
    [TestMethod]
    public override async Task SaveChangesAsync_ClearsTracking() => await base.SaveChangesAsync_ClearsTracking();
    [TestMethod]
    public override async Task SaveItem_ById_SavesSpecificItem() => await base.SaveItem_ById_SavesSpecificItem();
    [TestMethod]
    public override async Task SaveItem_WithTrackingState_SavesCorrectly() => await base.SaveItem_WithTrackingState_SavesCorrectly();
    [TestMethod]
    public override void SetTrackingStateToUpdate_MarksItemForUpdate() => base.SetTrackingStateToUpdate_MarksItemForUpdate();
    [TestMethod]
    public override void SetTrackingStateToUpdate_DoesNotChangeAddState() => base.SetTrackingStateToUpdate_DoesNotChangeAddState();
    [TestMethod]
    public override void TryGetTrackingItem_ReturnsTrue_WhenTracked() => base.TryGetTrackingItem_ReturnsTrue_WhenTracked();
    [TestMethod]
    public override void TryGetTrackingItem_ReturnsFalse_WhenNotTracked() => base.TryGetTrackingItem_ReturnsFalse_WhenNotTracked();
    [TestMethod]
    public override void TryRollbackItem_RevertsAddedItem() => base.TryRollbackItem_RevertsAddedItem();
    [TestMethod]
    public override async Task TryRollbackItem_RevertsUpdatedItem() => await base.TryRollbackItem_RevertsUpdatedItem();
    [TestMethod]
    public override void Rollback_RevertsAllChanges() => base.Rollback_RevertsAllChanges();
    [TestMethod]
    public override async Task Count_ReturnsCorrectValue() => await base.Count_ReturnsCorrectValue();
    [TestMethod]
    public override void Clear_RemovesAllItems() => base.Clear_RemovesAllItems();
    [TestMethod]
    public override void Clear_WithoutClearingTracking_PreservesTracking() => base.Clear_WithoutClearingTracking_PreservesTracking();
    [TestMethod]
    public override async Task Contains_ReturnsTrue_WhenItemExists() => await base.Contains_ReturnsTrue_WhenItemExists();
    [TestMethod]
    public override void Contains_ReturnsFalse_WhenItemNotExists() => base.Contains_ReturnsFalse_WhenItemNotExists();
    [TestMethod]
    public override async Task IndexOf_ReturnsCorrectIndex() => await base.IndexOf_ReturnsCorrectIndex();
    [TestMethod]
    public override void IndexOf_ById_ReturnsCorrectIndex() => base.IndexOf_ById_ReturnsCorrectIndex();
    [TestMethod]
    public override void TryGetIndex_ReturnsTrue_WhenExists() => base.TryGetIndex_ReturnsTrue_WhenExists();
    [TestMethod]
    public override async Task TryGetValue_ReturnsItem_WhenExists() => await base.TryGetValue_ReturnsItem_WhenExists();
    [TestMethod]
    public override void TryGetValue_ReturnsFalse_WhenNotExists() => base.TryGetValue_ReturnsFalse_WhenNotExists();
    [TestMethod]
    public override async Task CopyTo_CopiesAllItems() => await base.CopyTo_CopiesAllItems();
    [TestMethod]
    public override async Task GetEnumerator_EnumeratesAllItems() => await base.GetEnumerator_EnumeratesAllItems();
    [TestMethod]
    public override async Task AsReadOnly_ReturnsReadOnlyCollection() => await base.AsReadOnly_ReturnsReadOnlyCollection();
    [TestMethod]
    public override async Task SetWorkingReferenceList_SetsNewInnerList() => await base.SetWorkingReferenceList_SetsNewInnerList();
    [TestMethod]
    public override async Task GetReferenceInnerList_ReturnsInnerList() => await base.GetReferenceInnerList_ReturnsInnerList();
    [TestMethod]
    public override void IsSyncing_IsFalse_Initially() => base.IsSyncing_IsFalse_Initially();
    [TestMethod]
    public override async Task OnSyncingStateChanged_Fires_DuringLoad() => await base.OnSyncingStateChanged_Fires_DuringLoad();
    [TestMethod]
    public override void ContextIds_CanBeSetAndRetrieved() => base.ContextIds_CanBeSetAndRetrieved();
    [TestMethod]
    public override void CustomFilterCriteria_CanBeSetAndRetrieved() => base.CustomFilterCriteria_CanBeSetAndRetrieved();
    [TestMethod]
    public override void IList_Add_ReturnsCorrectIndex() => base.IList_Add_ReturnsCorrectIndex();
    [TestMethod]
    public override void IList_Contains_WorksCorrectly() => base.IList_Contains_WorksCorrectly();
    [TestMethod]
    public override void IList_IndexOf_WorksCorrectly() => base.IList_IndexOf_WorksCorrectly();
    [TestMethod]
    public override void IList_Insert_WorksCorrectly() => base.IList_Insert_WorksCorrectly();
    [TestMethod]
    public override void IList_Remove_WorksCorrectly() => base.IList_Remove_WorksCorrectly();
    [TestMethod]
    public override void IList_Indexer_GetSet_WorksCorrectly() => base.IList_Indexer_GetSet_WorksCorrectly();
    [TestMethod]
    public override void ICollection_CopyTo_WorksCorrectly() => base.ICollection_CopyTo_WorksCorrectly();
    [TestMethod]
    public override void IsSynchronized_ReturnsTrue() => base.IsSynchronized_ReturnsTrue();
    [TestMethod]
    public override void SyncRoot_IsNotNull() => base.SyncRoot_IsNotNull();
    [TestMethod]
    public override void IsFixedSize_ReturnsFalse() => base.IsFixedSize_ReturnsFalse();
    [TestMethod]
    public override void IsReadOnly_ReturnsFalse() => base.IsReadOnly_ReturnsFalse();
    [TestMethod]
    public override async Task Indexer_OutOfRange_ThrowsException() => await base.Indexer_OutOfRange_ThrowsException();
    [TestMethod]
    public override void Add_ThenRemove_ClearsTracking() => base.Add_ThenRemove_ClearsTracking();
    [TestMethod]
    public override async Task ComplexWorkflow_AddUpdateRemoveSave() => await base.ComplexWorkflow_AddUpdateRemoveSave();
    
    // Expression / AcLinq Filter Tests
    [TestMethod]
    public override async Task ExpressionFilter_WithQuantityGreaterThan_ReturnsFilteredItems() => await base.ExpressionFilter_WithQuantityGreaterThan_ReturnsFilteredItems();
    [TestMethod]
    public override async Task ExpressionFilter_WithUnitPriceGreaterThan_ReturnsFilteredItems() => await base.ExpressionFilter_WithUnitPriceGreaterThan_ReturnsFilteredItems();
    [TestMethod]
    public override async Task ExpressionFilter_WithNoFilter_ReturnsAllItems() => await base.ExpressionFilter_WithNoFilter_ReturnsAllItems();
    [TestMethod]
    public override async Task ExpressionFilter_WithProductNameContains_ReturnsFilteredItems() => await base.ExpressionFilter_WithProductNameContains_ReturnsFilteredItems();
    [TestMethod]
    public override async Task ExpressionFilter_WithComplexCondition_ReturnsFilteredItems() => await base.ExpressionFilter_WithComplexCondition_ReturnsFilteredItems();
}