Imports UTS_Core.Expression

Namespace UTSModule.Test.Command.ConverterCommand

    Public Class CompareExecutor
        Inherits TestCommandExecutor

        Private _strSource As String
        Private _compareType As String

        Sub New(command As TestCommand)
            MyBase.New(command)

            _strSource = TestCommand.Parameter(0)
            _compareType = TestCommand.Parameter(1)
            CommandReturn.LowerLimit = TestCommand.Parameter(2)
            CommandReturn.UpperLimit = TestCommand.Parameter(3)

            CommandReturn.RecordValue = String.Empty
            CommandReturn.ExecuteResultTipString = String.Empty
            CommandReturn.ExecuteResult = True
        End Sub

        Public Overrides Function Execute() As TestCommandReturn

            Select Case _compareType
                Case "1" '浮点比较
                    CommandReturn.ExecuteResult = CompareFunction.DoubleCompare(_strSource, CommandReturn.LowerLimit, CommandReturn.UpperLimit)
                Case "2" '字符串包含，包含字符串则返回true
                    CommandReturn.ExecuteResult = CompareFunction.StringContain(_strSource, CommandReturn.LowerLimit, CommandReturn.UpperLimit)
                Case "3" '字符串比较
                    CommandReturn.ExecuteResult = CompareFunction.StringCompare(_strSource, CommandReturn.LowerLimit, CommandReturn.UpperLimit)
                Case "4" 'Momo 2022-09-15 字符串比较，和StringContain 相反，不包含指定字符串则返回true
                    CommandReturn.ExecuteResult = CompareFunction.StringIsNotContain(_strSource, CommandReturn.LowerLimit, CommandReturn.UpperLimit)
                Case "5" 'Momo 2022-09-19 字符串全字匹配，等于upperlimit或lowwerlimit中的一个就返回true
                    CommandReturn.ExecuteResult = CompareFunction.StringEquals(_strSource, CommandReturn.LowerLimit, CommandReturn.UpperLimit)
                Case "6" 'Momo 2025-04-10 字符串长度比较，字符串长度在上下限范围以内
                    CommandReturn.ExecuteResult = CompareFunction.StringLengthCheck(_strSource, CommandReturn.LowerLimit, CommandReturn.UpperLimit)

                Case Else '默认字符串比较
                    CommandReturn.ExecuteResult = CompareFunction.StringCompare(_strSource, CommandReturn.LowerLimit, CommandReturn.UpperLimit)
            End Select


            If CommandReturn.ExecuteResult Then
                CommandReturn.RecordValue = "True"
                CommandReturn.ExecuteResultTipString = "数据在有效范围内"
            Else
                CommandReturn.RecordValue = "False"
                CommandReturn.ExecuteResultTipString = "数据在有效范围外"
            End If

            Return CommandReturn
        End Function
    End Class
End Namespace


