using System;
using System.Threading.Tasks;

namespace NavisworksTransport.UnitTests
{
    /// <summary>
    /// 用于测试的ViewModelBase实现
    /// </summary>
    public class TestViewModel : ViewModelBase
    {
        private string _testProperty;
        
        public string TestProperty
        {
            get => _testProperty;
            set => SetProperty(ref _testProperty, value);
        }

        /// <summary>
        /// 公开OnPropertyChanged方法用于测试
        /// </summary>
        public void TriggerPropertyChanged(string propertyName)
        {
            OnPropertyChanged(propertyName);
        }

        /// <summary>
        /// 公开OnPropertiesChanged方法用于测试
        /// </summary>
        public void TriggerPropertiesChanged(params string[] propertyNames)
        {
            OnPropertiesChanged(propertyNames);
        }

        /// <summary>
        /// 公开SetProperties方法用于测试
        /// </summary>
        public void TriggerSetProperties(params (string name, object value)[] properties)
        {
            SetProperties(properties);
        }

        /// <summary>
        /// 公开OnPropertyChangedAsync方法用于测试
        /// </summary>
        public async Task TriggerPropertyChangedAsync(string propertyName, int timeout = 3000)
        {
            await OnPropertyChangedAsync(propertyName, timeout);
        }

        /// <summary>
        /// 公开SafeExecute方法用于测试
        /// </summary>
        public void TestSafeExecute(Action action, string operationName)
        {
            SafeExecute(action, operationName);
        }

        /// <summary>
        /// 公开SafeExecute<T>方法用于测试
        /// </summary>
        public T TestSafeExecuteWithReturn<T>(Func<T> func, T defaultValue, string operationName)
        {
            return SafeExecute(func, defaultValue, operationName);
        }

        /// <summary>
        /// 公开SafeExecuteAsync方法用于测试
        /// </summary>
        public async Task TestSafeExecuteAsync(Action action, string operationName)
        {
            await SafeExecuteAsync(action, operationName);
        }
    }
}