using qdr.fnd.core.pqueue.Enums;
using qdr.fnd.core.pqueue.Storages;
using Quadarax.Foundation.Core.Data;
using Quadarax.Foundation.Core.Logging;

namespace qdr.fnd.core.pqueue.test.Storages.Mocks
{
    internal class BaseStorageProviderMock : BaseStorageProvider
    {
        public const string TestId = "TestId";
        public bool ReturnContainsItem { get; set; } = true;

        /// <inheritdoc />
        public BaseStorageProviderMock(ILogger? logger) : base(logger)
        {
        }

        #region Overrides of DisposableObject

        /// <inheritdoc />
        protected override void OnDisposing()
        {
        }

        #endregion

        #region Overrides of BaseStorageProvider

        /// <inheritdoc />
        protected override string OnCreateItem(string id, string owner, string ownerRef, string providerClass, int initialAttempts,
            DateTime created, string s)
        {
            return TestId;
        }

        /// <inheritdoc />
        protected override void OnDeleteItem(string itemId)
        {
        }

        /// <inheritdoc />
        protected override void OnUpdateItemPriority(string itemId, int priority)
        {
        }

        /// <inheritdoc />
        protected override void OnUpdateItemValidity(string itemId, DateTime validForm, DateTime? validTo)
        {
        }

        /// <inheritdoc />
        protected override void OnUpdateItemStatus(string itemId, PsStatusEnum? status, bool isTransient)
        {
        }

        /// <inheritdoc />
        protected override void OnUpdateItemAttempts(string itemId, int attemptsLeft)
        {
        }

        /// <inheritdoc />
        protected override void OnUpdateItemStarted(string itemId, DateTime? started)
        {
        }

        /// <inheritdoc />
        protected override void OnUpdateItemFinished(string itemId, DateTime? finished)
        {
        }

        /// <inheritdoc />
        protected override void OnCreateItemAttribute(string itemId, string name, string? value, string valueTypeClass, bool isOutput)
        {
        }

        /// <inheritdoc />
        protected override void OnUpdateItemAttribute(string itemId, string name, string value)
        {
            throw new NotImplementedException();
        }

        /// <inheritdoc />
        protected override void OnDeleteItemAttribute(string itemId, string name)
        {
            throw new NotImplementedException();
        }

        /// <inheritdoc />
        protected override void OnAppendLog(string itemId, string message, int code, ErrorLevelEnum messageType)
        {
        }

        /// <inheritdoc />
        protected override void OnAppendStatusJournal(string itemId, PsStatusEnum status, bool isTransient, string message)
        {
        }

        /// <inheritdoc />
        protected override IQueryable<IPsQueueItem> OnQuery()
        {
            return new List<IPsQueueItem>().AsQueryable();
        }

        /// <inheritdoc />
        protected override IPsQueueItem OnGetItem(string itemId)
        {
            return new PsQueueItem(itemId);
        }

        /// <inheritdoc />
        public override bool ContainsItem(string itemId)
        {
            return ReturnContainsItem;
        }

        #endregion
    }
}
