using System;
using System.Diagnostics;

namespace CryptoExchange.Net.Testing
{
    internal class EnumValueTraceListener : TraceListener
    {
        public override void Write(string? message)
        {
            if (message == null)
                return;

            if (message.Contains("Cannot map"))
                throw new Exception("Enum value error: " + message);

            if (message.Contains("Received null or empty enum value"))
                throw new Exception("Enum null error: " + message);

            if (message.Contains("Enum mapping sub-optimal."))
                throw new Exception("Enum mapping error: " + message);
        }

        public override void WriteLine(string? message)
        {
            if (message == null)
                return;

            if (message.Contains("Cannot map"))
                throw new Exception("Enum value error: " + message);

            if (message.Contains("Received null or empty enum value"))
                throw new Exception("Enum null error: " + message);

            if (message.Contains("Enum mapping sub-optimal."))
                throw new Exception("Enum mapping error: " + message);
        }
    }
}
