`

Console Framework

 
阅读更多
    先把标题开着,下面准备实现控制台程序的基本框架,以后就准备直接拷贝使用

    我写的这一个Console Framework是一个简单的带参数的控制台程序的基本框架,如果有很好的建议,欢迎大家拍砖!

    这简单的框架主要包括以下几个部分:
    1)Error的定义和管理,可以参考我的另一篇bolghttp://jacky-dai.iteye.com/admin/blogs/1306613
    2)Command Handler的定义和实现;
    3)Function Dispatcher的实现;
    4) main函数的构建;


    看明白这个例子之后,以后只要需要些console app的地方可以直接试用,只要针对不同的Command添加XXhandler, 然后再添加到Dispatcher中去,最后再main中支持相对应的Command

  
ErrorCode框架定义

/**************************************************************************************************/
/*!
    \file CommonErrors.h

    \attention
        (c) Jacky Dai 2011~2016
        All Rights Reserved.
*/

/**************************************************************************************************/

#ifndef XX_COMMON_ERRORS_H
#define XX_COMMON_ERRORS_H

/*** Include Files ********************************************************************************/

/*** Defines/Macros/Constants/Typedefs ************************************************************/

namespace CommonErrorSpace
{
//basic mask code
const unsigned int COMPONENT_MASK       = 0x8000;

//component code
const unsigned int COMPONENT_LOGIN            = 0x0001;
const unsigned int COMPONENT_DATAMANAGER      = 0x0002;

//
//0x0000XXXX:XXXX means component code
//0xXXXX0000:XXXX means error code of component

//Define some marcos/functions here
#define SYSTEM_ERROR_FLAG (0x4000)
#define SYSTEM_ERROR(code) ((code | SYSTEM_ERROR_FLAG) << 16)
#define ERROR_IS_SYSTEM_ERROR(err) (((err >> 16) & SYSTEM_ERROR_FLAG) != 0)

#define COMPONENT_ERROR(component, code) ((code << 16) | (component & ~(COMPONENT_MASK)))
#define CODE_FROM_ERROR(err) (static_cast<short>(err >> 16))

//All of the error code is here
typedef enum
{
                                                                                 //   Hex        | Decimal       | Descriptio
    //Basic error
    ERR_OK                                 = 0x00000000,                         //<< 0x00000000 |  0            | No error.
    ERR_SYSTEM                             = SYSTEM_ERROR(1),                    //<< 0x00010000 | 65536         | General system error.
    ERR_TIMEOUT                            = SYSTEM_ERROR(2),                    //<< 0x00020000 | 131072        | Time out.
    
    //login component
    LOGIN_ERROR_UNKNOWN_ERROR              = COMPONENT_ERROR(COMPONENT_LOGIN, 1),     //<< 0x00010001 |65537    | Unrecognized error.
    LOGIN_ERROR_UNKNOWN_USER_NAME          = COMPONENT_ERROR(COMPONENT_LOGIN, 2),     //<< 0x00020001 |131073   | Unrecognized user name, it is case sensitive.
    
    //data manager component
    DATAMANAGER_ERROR_UNKNOWN_ERROR        = COMPONENT_ERROR(COMPONENT_DATAMANAGER, 1), //<< 0x00010002 |65538   | Unrecognized error.
    DATAMANAGER_ERROR_MISSING_CONNECTION   = COMPONENT_ERROR(COMPONENT_DATAMANAGER, 2)  //<< 0x00020002 |131074   | Connection missed.
} CommonError;


/**************************************************************************************************/
/*!
    \class ErrorHelper

    Class with commands for translating error codes to useful strings.

*/
/**************************************************************************************************/
class ErrorHelper
{
public:
    static const char* getErrorName(CommonError error);
    static const char* getErrorDescription(CommonError error);
};

} // CommonErrorSpace

#endif //XX_COMMON_ERRORS_H

/**************************************************************************************************/
/*!
    \file CommonErrors.cpp

    \attention
        (c) Jacky Dai 2011~2016
        All Rights Reserved.
*/

/**************************************************************************************************/

/*** Include Files ********************************************************************************/
#include "CommonErrors.h"

/*** Defines/Macros/Constants/Typedefs ************************************************************/

namespace CommonErrorSpace
{
/*** Public Methods ******************************************************************************/
const char* ErrorHelper::getErrorName(CommonError error)
{
    const char* result = "UKNOWN";

    switch (error)
    {
        case ERR_OK: result = "ERR_OK"; break;
        case ERR_SYSTEM: result = "ERR_SYSTEM"; break;
        case ERR_TIMEOUT: result = "ERR_TIMEOUT"; break;
        case LOGIN_ERROR_UNKNOWN_ERROR: result = "LOGIN_ERROR_UNKNOWN_ERROR"; break;
        case LOGIN_ERROR_UNKNOWN_USER_NAME: result = "LOGIN_ERROR_UNKNOWN_USER_NAME"; break;
        case DATAMANAGER_ERROR_UNKNOWN_ERROR: result = "DATAMANAGER_ERROR_UNKNOWN_ERROR"; break;
        case DATAMANAGER_ERROR_MISSING_CONNECTION: result = "DATAMANAGER_ERROR_MISSING_CONNECTION"; break;
        default: break;
    }

    return result;
}

const char* ErrorHelper::getErrorDescription(CommonError error)
{
    const char *result = "UKNOWN";

    switch (error)
    {
        case ERR_OK: result = "No error."; break;
        case ERR_SYSTEM: result = "General system error."; break;
        case ERR_TIMEOUT: result = "Time out."; break;
        case LOGIN_ERROR_UNKNOWN_ERROR: result = "Unrecognized error."; break;
        case LOGIN_ERROR_UNKNOWN_USER_NAME: result = "Unrecognized user name, it is case sensitive."; break;
        case DATAMANAGER_ERROR_UNKNOWN_ERROR: result = "Unrecognized error."; break;
        case DATAMANAGER_ERROR_MISSING_CONNECTION: result = "Connection missed."; break;
        default: break;
    }

    return result;
}

} // CommonErrorSpace


  
Command Handler

/**************************************************************************************************/
/*!
    \file CommonHandler.h

    \attention
        (c) Jacky Dai 2011~2016
        All Rights Reserved.
*/

/**************************************************************************************************/
#ifndef COMMAND_HANDLER_H
#define COMMAND_HANDLER_H

#include <windows.h>
#include <string>
#include "CommonErrors.h"
using namespace std;
using namespace CommonErrorSpace;

//
//////////////////////////////////////////////////////////////////////
class HandlerBase
{
public:
    HandlerBase(){}
    virtual ~HandlerBase(){};

    virtual CommonError Parser(LPCSTR lpCommand) = 0;
    virtual VOID ShowInfo() = 0;
    virtual VOID HelpInfo(BOOL bDetail) = 0;

protected:
//     VOID CatchError(string strMsg)
//     {
//         cout << "\nError!" << endl;
//         cout << strMsg.c_str() << endl;
//     }
// 
//     VOID GetAPIErrorInfo(CommonErrorSpace::CommonError errorCode)
//     {
//         cout << "\nError!\nCall " << m_strFuncName << "Failed!" << endl;
//         cout << "ErrorCode = 0x" << setw(8) << setfill('0') << hex << errorCode << endl;
//         cout << CommonErrorSpace::ErrorHelper::getErrorName(errorCode) << endl;
//         cout << CommonErrorSpace::ErrorHelper::getErrorDescription(errorCode) << endl;
//     }

protected:
    string m_strFuncName;
};

//AlgorithmType
//////////////////////////////////////////////////////////////////////
class LoginHandler : public HandlerBase
{
public:
    typedef enum
    {  
        ERR_OK                        = CommonErrorSpace::ERR_OK,
        ERR_SYSTEM                    = CommonErrorSpace::ERR_SYSTEM,
        ERR_TIMEOUT                   = CommonErrorSpace::ERR_TIMEOUT,
        LOGIN_ERROR_UNKNOWN_ERROR     = CommonErrorSpace::LOGIN_ERROR_UNKNOWN_ERROR,
        LOGIN_ERROR_UNKNOWN_USER_NAME = CommonErrorSpace::LOGIN_ERROR_UNKNOWN_USER_NAME
    } Errors; 

    LoginHandler(string strFuncName = "Login")
    {
        m_strFuncName = strFuncName;
    }

    virtual CommonError Parser(LPCSTR lpCommand);
    virtual VOID HelpInfo(BOOL bDetail);
    virtual VOID ShowInfo();

private:
    void Login();

private:
    string m_strUserName;
    string m_strUserPwd;
};

////////////////////////////////////////////
class DataManagerHandler : public HandlerBase
{
public:
    typedef enum
    {
        ERR_OK                               = CommonErrorSpace::ERR_OK,
        ERR_SYSTEM                           = CommonErrorSpace::ERR_SYSTEM,
        ERR_TIMEOUT                          = CommonErrorSpace::ERR_TIMEOUT,
        DATAMANAGER_ERROR_UNKNOWN_ERROR      = CommonErrorSpace::DATAMANAGER_ERROR_UNKNOWN_ERROR,
        DATAMANAGER_ERROR_MISSING_CONNECTION = CommonErrorSpace::DATAMANAGER_ERROR_MISSING_CONNECTION
    } Errors; 

    DataManagerHandler(string strFuncName = "DataManager")
    {
        m_strFuncName = strFuncName;
    }

    virtual CommonError Parser(LPCSTR lpCommand);
    virtual VOID ShowInfo();
    virtual VOID HelpInfo(BOOL bDetail);

private:
    void DataManager();

private:
    string m_strDmName;
    string m_strDmPort;
};

#endif//COMMAND_HANDLER_H

#include "CommandHandler.h"
#include<algorithm>
#include <iostream>
using namespace std;

//Login
////////////////////////////////////////////
CommonError LoginHandler::Parser(LPCSTR lpCommand)
{
    CommonErrorSpace::CommonError error = static_cast<CommonErrorSpace::CommonError>(ERR_OK);
    if (NULL == lpCommand)
    {
        HelpInfo(TRUE);

        error = static_cast<CommonErrorSpace::CommonError>(ERR_SYSTEM);
        cout << ErrorHelper::getErrorName(error) << endl;
        cout << ErrorHelper::getErrorDescription(error) << endl;

        return error;
    }
    else
    {
        string strCommand = lpCommand;
        string strBKCommand = lpCommand;
        transform(strCommand.begin(),strCommand.end(),strCommand.begin(), tolower);

         //Get Param1
        /////////////////////////////////////////////////////////////////////////////////////
        size_t nTypePos = strCommand.find("name=");
        size_t nOffSet = 5;
        if (nTypePos != string::npos)
        {
            size_t nCommaPos = strCommand.find_first_of(',', nTypePos);

            if (nCommaPos != string::npos)
            {
                m_strUserName = strBKCommand.substr(nTypePos+nOffSet, nCommaPos-nTypePos-nOffSet);
            }
            else
            {
                m_strUserName = strBKCommand.substr(nTypePos+nOffSet);
            }

        }
        else
        {
            HelpInfo(TRUE);

            error = static_cast<CommonErrorSpace::CommonError>(LOGIN_ERROR_UNKNOWN_USER_NAME);
            cout << ErrorHelper::getErrorName(error) << endl;
            cout << ErrorHelper::getErrorDescription(error) << endl;

            return error;
        }

        //Get Param2
        //////////////////////////////////////////////////////////////////////////
        nTypePos = strCommand.find("password=");
        nOffSet = 9;
        if (nTypePos != string::npos)
        {
            size_t nCommaPos = strCommand.find_first_of(',', nTypePos);

            if (nCommaPos != string::npos)
            {
                m_strUserPwd = strBKCommand.substr(nTypePos+nOffSet, nCommaPos-nTypePos-nOffSet);
            }
            else
            {
                m_strUserPwd = strBKCommand.substr(nTypePos+nOffSet);
            }

        }
        else
        {
            HelpInfo(TRUE);

            error = static_cast<CommonErrorSpace::CommonError>(LOGIN_ERROR_UNKNOWN_ERROR);
            cout << ErrorHelper::getErrorName(error) << endl;
            cout << ErrorHelper::getErrorDescription(error) << endl;

            return error;
        }

        Login(); //All parameters are ok, try to call local API
        ShowInfo();

        cout << ErrorHelper::getErrorName(error) << endl;
        cout << ErrorHelper::getErrorDescription(error) << endl;
        return static_cast<CommonErrorSpace::CommonError>(error);
    }
}

VOID LoginHandler::HelpInfo(BOOL bDetail)
{
    transform(m_strFuncName.begin(), m_strFuncName.end(), m_strFuncName.begin(), toupper);
    if (!bDetail)
    {
        cout << m_strFuncName.c_str() << "          Login the server.";
    }
    else
    {
        cout << '\n' << m_strFuncName.c_str() << endl;
        cout << " [Name=#NAME]" << endl;
        cout << "    [NAME] User name for server" << endl;
        cout << " [Password=#PWD]" << endl;
        cout << "    [PWD] User password for server" << endl;
    }
}

VOID LoginHandler::ShowInfo()
{
    cout << "\nSucceed!\n" << endl;

    cout << "\nRSP==>\n";
    cout << "Login = {" << endl;
    cout << "    name = " << m_strUserName.c_str() << endl;
    cout << "    password = " << m_strUserPwd.c_str() << endl;
    cout << "}" << endl;
}

void LoginHandler::Login()
{
    cout << "Do login state......\n";
}

//DataManager
//////////////////////////////////////////////////////////////////////////
CommonError DataManagerHandler::Parser(LPCSTR lpCommand)
{
    CommonErrorSpace::CommonError error = static_cast<CommonErrorSpace::CommonError>(ERR_OK);
    if (NULL == lpCommand)
    {
        HelpInfo(TRUE);

        error = static_cast<CommonErrorSpace::CommonError>(ERR_SYSTEM);
        cout << ErrorHelper::getErrorName(error) << endl;
        cout << ErrorHelper::getErrorDescription(error) << endl;

        return error;
    }
    else
    {
        string strCommand = lpCommand;
        string strBKCommand = lpCommand;
        transform(strCommand.begin(),strCommand.end(),strCommand.begin(), tolower);

        //Get Param1
        /////////////////////////////////////////////////////////////////////////////////////
        size_t nTypePos = strCommand.find("name=");
        size_t nOffSet = 5;
        if (nTypePos != string::npos)
        {
            size_t nCommaPos = strCommand.find_first_of(',', nTypePos);

            if (nCommaPos != string::npos)
            {
                m_strDmName = strBKCommand.substr(nTypePos+nOffSet, nCommaPos-nTypePos-nOffSet);
            }
            else
            {
                m_strDmName = strBKCommand.substr(nTypePos+nOffSet);
            }

        }
        else
        {
            HelpInfo(TRUE);

            error = static_cast<CommonErrorSpace::CommonError>(ERR_TIMEOUT);
            cout << ErrorHelper::getErrorName(error) << endl;
            cout << ErrorHelper::getErrorDescription(error) << endl;

            return error;
        }

        //Get Param2
        //////////////////////////////////////////////////////////////////////////
        nTypePos = strCommand.find("port=");
        nOffSet = 5;
        if (nTypePos != string::npos)
        {
            size_t nCommaPos = strCommand.find_first_of(',', nTypePos);

            if (nCommaPos != string::npos)
            {
                m_strDmPort = strBKCommand.substr(nTypePos+nOffSet, nCommaPos-nTypePos-nOffSet);
            }
            else
            {
                m_strDmPort = strBKCommand.substr(nTypePos+nOffSet);
            }

        }
        else
        {
            HelpInfo(TRUE);
            error = static_cast<CommonErrorSpace::CommonError>(DATAMANAGER_ERROR_MISSING_CONNECTION);
            cout << ErrorHelper::getErrorName(error) << endl;
            cout << ErrorHelper::getErrorDescription(error) << endl;

            return error;
        }

        DataManager(); //All parameters are ok, try to call local API
        ShowInfo();

        cout << ErrorHelper::getErrorName(error) << endl;
        cout << ErrorHelper::getErrorDescription(error) << endl;
        return error;
    }
}

VOID DataManagerHandler::ShowInfo()
{
    cout << "\nSucceed!\n" << endl;

    cout << "\nRSP==>\n";
    cout << "DataManager = {" << endl;
    cout << "    Name = " << m_strDmName.c_str() << endl;
    cout << "    Port = " << m_strDmPort.c_str() << endl;
    cout << "}" << endl;
}

VOID DataManagerHandler::HelpInfo(BOOL bDetail)
{
    transform(m_strFuncName.begin(), m_strFuncName.end(), m_strFuncName.begin(), toupper);
    if (!bDetail)
    {
        cout << m_strFuncName.c_str() << "          Connect to Data server.";
    }
    else
    {
        cout << '\n' << m_strFuncName.c_str() << endl;
        cout << " [Name=#NAME]" << endl;
        cout << "    [NAME] Data server name" << endl;
        cout << " [Port=#PORT]" << endl;
        cout << "    [PORT] Data server port" << endl;
    }
}

 void DataManagerHandler::DataManager()
 {
     cout << "Do data manager......\n";
 }


  
Function Dispatcher

/**************************************************************************************************/
/*!
    \file FuncDispatcher.h

    \attention
        (c) Jacky Dai 2011~2016
        All Rights Reserved.
*/

/**************************************************************************************************/
#ifndef FUNC_DISPATCHER_H
#define FUNC_DISPATCHER_H

#include <map>
#include "CommandHandler.h"
using namespace std;

typedef map<string, HandlerBase*> Dispatcher;

class FuncDispatcher
{
public:
    FuncDispatcher();
    ~FuncDispatcher();

    VOID Init();
    VOID Clear();
    VOID ShowHelpInfo(BOOL bDetailInfo);
    HandlerBase* FindHandler(LPCSTR lpFuncName);

private:
    Dispatcher m_Dispatcher;
};

#endif//FUNC_DISPATCHER_H

#include "FuncDispatcher.h"
#include "CommandHandler.h"
#include <iostream>
using namespace std;

FuncDispatcher::FuncDispatcher()
{
    Init();
}

FuncDispatcher::~FuncDispatcher()
{
    Clear();
}

VOID FuncDispatcher::Init()
{
    m_Dispatcher.insert(make_pair("login", new LoginHandler()));
    m_Dispatcher.insert(make_pair("datamanager", new DataManagerHandler()));
}

VOID FuncDispatcher::Clear()
{
    Dispatcher::const_iterator iter = m_Dispatcher.begin();
    Dispatcher::const_iterator end = m_Dispatcher.end();
    for ( ; iter!=end; ++iter)
    {
        delete iter->second;
    }

    m_Dispatcher.clear();
}

VOID FuncDispatcher::ShowHelpInfo(BOOL bDetailInfo)
{
    Dispatcher::const_iterator iter = m_Dispatcher.begin();
    Dispatcher::const_iterator end = m_Dispatcher.end();
    for ( ; iter!=end; ++iter)
    {
        iter->second->HelpInfo(bDetailInfo);
        cout << endl;
    }
}

HandlerBase* FuncDispatcher::FindHandler(LPCSTR lpFuncName)
{
    if (NULL==lpFuncName)
    {
        return NULL;
    }

    string strTemp = lpFuncName;
    Dispatcher::const_iterator item = m_Dispatcher.find(lpFuncName);
    if (item == m_Dispatcher.end())
    {
        return NULL;
    }
    else
    {
        return item->second;
    }

    return NULL;
}


  
main函数

/*************************************************************************************************/
/*!
    \file   main.cpp

    \ Author      : Jacky Dai
    \ Version     : Ver 1.0.0.0
    \ Date        : 2016-07-11
    \ Copyright   : All Rights Reserved.
    \ Description : 
    \Usage        : 
*/
/*************************************************************************************************/
#include "FuncDispatcher.h"
#include<algorithm>
#include <iostream>
using namespace std;

const string STR_HELP_API         = "help";
const string STR_LOGIN_API        = "login";
const string STR_DATA_MANAGER_API = "datamanager";


FuncDispatcher g_FuncDispatcher;

//////////////////////////////////////////////////////////////////////////
int main(int argc, char** argv)
{
    if (1 == argc)
    {
        //There is no command, so do nothing.
        cout << "Do nothing!" << endl;
        return 0;
    }
    else
    {
        //TODO
        //Load default parameters
    }

    for(int argIndex = 1; argIndex < argc; ++argIndex)
    {
        HandlerBase* pCommandHandler = NULL;
        string strCommandName = argv[argIndex];
        string strBKCommandName = argv[argIndex];
        transform(strCommandName.begin(),strCommandName.end(),strCommandName.begin(), tolower);
        if (STR_HELP_API == strCommandName)
        {
            if (2 == argc) //Show all help info
            {
                cout << '\n';
                g_FuncDispatcher.ShowHelpInfo(FALSE);
            }
            else if (3 == argc) //Show single API help info
            {
                strCommandName = argv[argc-1];
                strBKCommandName = argv[argc-1];
                transform(strCommandName.begin(),strCommandName.end(),strCommandName.begin(), tolower);
                pCommandHandler = g_FuncDispatcher.FindHandler(strCommandName.c_str());
                if (pCommandHandler != NULL)
                {
                    pCommandHandler->HelpInfo(TRUE);
                }
                else
                {
                    cout << "\n\"" << strBKCommandName << "\"" << " is not a supported command!" << endl;
                    return -1;
                }
            }
            else
            {
                cout << "\nHelp [CMD]"  << endl;
                cout << "[CMD] Show detail help information for the command." << endl;
                return -1;
            }

            return 0;
        }
        else
        {
            pCommandHandler = g_FuncDispatcher.FindHandler(strCommandName.c_str());
            if (NULL == pCommandHandler)
            {
                cout << "\n\"" << strBKCommandName << "\" is a invalid Command!" << endl;
                return -1;
            }

            if (STR_LOGIN_API==strCommandName
            || STR_DATA_MANAGER_API==strCommandName)
            {
                if (argc >= 3)
                {
                    argIndex++;
                    strCommandName = argv[argIndex];
                    strBKCommandName = argv[argIndex];
                    pCommandHandler->Parser(strCommandName.c_str());
                    break;
                }
                else
                {
                    pCommandHandler->Parser(NULL); //Means the API does not contains parameters
                    break;
                }
            }
            else if (pCommandHandler != NULL)
            {
                //other commands
                pCommandHandler->ShowInfo();
                break;
            }
            else
            {
                cout << "Unknown Exception!" << endl;
                return -1;
            }
        }
    }

    return 0;
}


测试脚本

@ECHO OFF
ECHO -------------------Unit Test for "Help" Command-----------------------
TITLE "Help" Command Test.

REM /////////////////////////////////////////////////////////////////////////////////
ECHO -- Case 1:Call all help info 
ECHO -- Expected Resut: Show all API help info
REM Show all API help info
REM ---------------------------------------------------------------------------------
ECHO COMMAND:ConsoleFrameworkDemo Help
ConsoleFrameworkDemo Help
IF "%1" == "" PAUSE


REM /////////////////////////////////////////////////////////////////////////////////
ECHO -- Case 2:Call help info of Login
ECHO -- Expected Resut: Show all Login help info
REM Show all login help info
REM ---------------------------------------------------------------------------------
ECHO COMMAND:ConsoleFrameworkDemo Help Login
ConsoleFrameworkDemo Help login
IF "%1" == "" PAUSE


REM /////////////////////////////////////////////////////////////////////////////////
ECHO -- Case 3:Call help info of DataManager
ECHO -- Expected Resut: Show all DataManager help info
REM Show all datamanager help info
REM ---------------------------------------------------------------------------------
ECHO COMMAND:ConsoleFrameworkDemo Help DataManager
ConsoleFrameworkDemo Help DataManager
IF "%1" == "" PAUSE

@ECHO OFF
ECHO -------------------Unit Test for "Login" Command-----------------------
TITLE "Login" Command Test.

REM /////////////////////////////////////////////////////////////////////////////////
ECHO -- Case 1:Does no pass any parameters for Login API 
ECHO -- Expected Resut: Show Login usge info
REM Show Login usge info
REM ---------------------------------------------------------------------------------
ECHO COMMAND:ConsoleFrameworkDemo Login
ConsoleFrameworkDemo Login
IF "%1" == "" PAUSE


REM /////////////////////////////////////////////////////////////////////////////////
ECHO -- Case 2:pass one parameter for Login API 
ECHO -- Expected Resut: Show Login usge info
REM Show Login usge info
REM ---------------------------------------------------------------------------------
ECHO COMMAND:ConsoleFrameworkDemo Login Name="Jacky"
ConsoleFrameworkDemo Login Name="Jacky"
IF "%1" == "" PAUSE

REM /////////////////////////////////////////////////////////////////////////////////
ECHO -- Case 3:pass two parameters for Login API 
ECHO -- Expected Resut: Should handler it well
REM Should handler it well
REM ---------------------------------------------------------------------------------
ECHO COMMAND:ConsoleFrameworkDemo Login Name="Jacky",Password="123"
ConsoleFrameworkDemo Login Name="Jacky",Password="123"
IF "%1" == "" PAUSE

@ECHO OFF
ECHO -------------------Unit Test for "DataManager" Command-----------------------
TITLE "DataManager" Command Test.

REM /////////////////////////////////////////////////////////////////////////////////
ECHO -- Case 1:Does no pass any parameters for DataManager API 
ECHO -- Expected Resut: Show DataManager usge info
REM Show DataManager usge info
REM ---------------------------------------------------------------------------------
ECHO COMMAND:ConsoleFrameworkDemo DataManager
ConsoleFrameworkDemo DataManager
IF "%1" == "" PAUSE


REM /////////////////////////////////////////////////////////////////////////////////
ECHO -- Case 2:pass one parameter for DataManager API 
ECHO -- Expected Resut: Show DataManager usge info
REM Show DataManager usge info
REM ---------------------------------------------------------------------------------
ECHO COMMAND:ConsoleFrameworkDemo DataManager Name="Jacky"
ConsoleFrameworkDemo DataManager Name="Jacky"
IF "%1" == "" PAUSE

REM /////////////////////////////////////////////////////////////////////////////////
ECHO -- Case 3:pass two parameters for DataManager API 
ECHO -- Expected Resut: Should handler it well
REM Should handler it well
REM ---------------------------------------------------------------------------------
ECHO COMMAND:ConsoleFrameworkDemo DataManager Name="Jacky",Port="123"
ConsoleFrameworkDemo DataManager Name="Jacky",Port="123"
IF "%1" == "" PAUSE
分享到:
评论

相关推荐

    citrix XenApp 5.0卸载步骤

    - Citrix Access Management Console Framework - Presentation Server Console - Citrix Presentation Server - Citrix Web Interface - License Management Console - Citrix Presentation Server Document ...

    易语言CF皮肤列表框

    2. **皮肤应用**:CF皮肤是控制台框架(Console Framework,简称CF)提供的一种美化界面的方式。要将CF皮肤应用到列表框上,需要导入相应的皮肤库,并调用相应的函数或方法设置皮肤样式。 3. **事件处理**:在描述...

    ZEND FRAMEWORK 1.11.7 中文参考文档

    Table of Contents •Introduction to Zend Framework •Overview •Installation •Learning Zend Framework •Zend Framework Quick Start •Autoloading in Zend Framework •Plugins in Zend Framework •...

    ATF Console.zip

    ATF Console.zip是一个与WDI(Wise Device Interface)技术相关的软件包,主要涉及的核心是ATF(Autofocus Technology Framework)。WDI是一种先进的设备接口技术,它集成了多种功能,如激光对焦和自动对焦,以实现...

    ConsoleApplication1_zip_consoleapplication_

    在编程领域,特别是C#或.NET Framework中,一个`Console Application`是指一种程序类型,它的主要功能是通过控制台窗口接收输入和输出信息。这种类型的程序常用于教学、调试或简单的脚本任务,因为它们易于创建和...

    ConsoleFramework

    C#拥有丰富的库支持和强大的类型系统,是.NET Framework和.NET Core平台的核心组成部分。 ConsoleFramework充分利用了C#的特性,提供了一套结构化的方式来处理命令行输入、参数解析、选项配置以及错误处理。开发者...

    console-com 口驱动

    在Win7、XP和2003这样的Windows系统中,驱动程序通常采用用户模式驱动程序框架(User-Mode Driver Framework, UMDF)或内核模式驱动程序框架(Kernel-Mode Driver Framework, KMDF)进行开发,以确保安全性和稳定性...

    c# console例程

    1. **项目创建**:打开Visual Studio,选择"新建项目",在模板列表中找到"C# Console App (.NET Core)"或"C# Console App (.NET Framework)",根据你的需求选择合适的平台版本。给项目命名为“zhh_console”。 2. *...

    C#课件Net FrameWork简介

    【C# 与 .NET Framework 简介】 C# 是一种由微软公司设计的面向对象的编程语言,专门用于构建基于 .NET Framework 的应用程序。.NET Framework 是一个全面的开发平台,它提供了运行和构建应用程序所需的环境。C# ...

    .NET Framework 版本检测代码

    Console.WriteLine($"运行的.NET Framework版本: {frameworkVersion}"); } } ``` 这段代码将输出类似于“运行的.NET Framework版本: 4.0.30319.42000”的信息。这里的4.0.30319.42000分别代表主版本、次版本、...

    RobotFramework二次开发小结.doc

    ### RobotFramework二次开发小结 #### 一、引言 RobotFramework是一款强大的自动化测试框架,支持多种编程语言和测试环境。对于需要定制化扩展功能的需求,RobotFramework支持二次开发,以便更好地满足特定项目的...

    Kafka .Net Framework4.0 版本

    Console.WriteLine($"Consumed message '{consumeResult.Message.Value}' at: '{consumeResult.Message.Timestamp}'"); } } ``` `3rdParty`目录可能包含了Kafka .Net库所依赖的第三方组件,这些组件可能包含各种...

    Framework Design Guidelines Digest

    ### Framework Design Guidelines Digest #### 一、概述与背景 《Framework Design Guidelines Digest》是一份精简版文档,基于Krzysztof Cwalina和Brad Abrams所著的《Framework Design Guidelines》一书中的核心...

    USB-COM口驱动,console线驱动

    而在Windows下,开发者可能需要使用Windows Driver Kit (WDK)和Kernel-Mode Driver Framework (KMDF)来编写驱动代码。 在实际应用中,USB-COM口驱动和console线驱动广泛应用于工业自动化、物联网设备、远程监控等...

    consoleframework:跨平台工具包,用于轻松开发TUI应用程序

    控制台框架 控制台框架是跨平台工具包,它允许使用C#和基于WPF的概念来开发应用程序。 产品特点 声明性标记(自定义轻量级XAML实现) 数据绑定(与XAML标记集成) 保留模式渲染系统 与WPF兼容的简单灵活的布局...

    C-sharp-console-gui-framework:用于C#控制台应用程序的GUI框架

    控制台GUI ConsoleGUI是一个简单的布局驱动的.NET框架,用于创建基于控制台的GUI应用程序。 它提供了最基本的布局管理实用程序以及一组基本控件。 上面的示例并不是真正的可玩象棋游戏。 左侧的面板只是一个带有一些...

    自己开发的OSGi Web Console

    1、自己开发的OSGi Web Console,适用于实现了OSGi规范的Equinox、Felix等开源框架,可在web界面上启动、停止OSGi Framework,启动、停止、装载、卸载bundles。当切换成其他OSGi开源框架时,只需在把lib下面的jar...

    web框架net-framework1

    Console.WriteLine("Hello, World!"); } } } ``` ### Chapter 3: Acronym Glossary .NET相关的缩略词包括ASP.NET(用于构建Web应用程序)、ADO.NET(数据访问技术)、WPF(Windows Presentation Foundation,UI...

Global site tag (gtag.js) - Google Analytics