Example #1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="render"></param>
        /// <param name="info"></param>
        public ServerPlayingState(LogicInfo info, MainGameHubServerImpl hub) : base(info)
        {
            hubImpl = hub;

            pauseState      = new ServerPauseState(input);
            deleteLineState = new ServerDeleteLineState();
            deleteLineState.InitializeBeforeEnter(boardInfo);
        }
Example #2
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="render"></param>
        /// <param name="info"></param>
        public AlonePlayingState(LogicInfo info, AloneInfo ctrlInfo) : base(info)
        {
            viewer = ctrlInfo.viewer;

            pauseState      = new AlonePauseState(input);
            deleteLineState = new AloneDeleteLineState();
            deleteLineState.InitializeBeforeEnter(boardInfo, viewer);
        }
Example #3
0
        /// <summary>
        /// 通过加载测试逻辑的dll来反射出所有的测试逻辑与测试集
        /// </summary>
        /// <param name="fileName"></param>
        void LoadTestCase(string fileName)
        {
            lstLogicInfo.Clear();
            try
            {
                this.logicFileName = fileName;
                //这种方式加载程序集是直接加载文件.
                //this.asmPlugin = Assembly.LoadFile(fileName);
                byte[] assemblyInfo = File.ReadAllBytes(this.logicFileName);
                this.asmPlugin = Assembly.Load(assemblyInfo);

                //遍历程序集中的所有测试逻辑
                foreach (var item in asmPlugin.GetTypes())
                {
                    //如果程序集中有继承ILogic的类,则就是测试逻辑.
                    if (item.GetInterface(typeof(ILogic).ToString()) == null || !item.IsClass)
                    {
                        continue;
                    }

                    //如果在测试逻辑链表中找到该测试逻辑则跳过
                    var logicInfo = lstLogicInfo.FirstOrDefault <LogicInfo>(src =>
                    {
                        return(src.logic.GetType().FullName.Equals(item.FullName));
                    });

                    //未找到该测试逻辑则new测试逻辑加入测试链表中
                    if (logicInfo == null && !item.FullName.Contains(" "))
                    {
                        try
                        {
                            //实例化该测试逻辑
                            var iLogic = asmPlugin.CreateInstance(item.FullName, true) as ILogic;
                            if (iLogic == null)
                            {
                                throw new Exception("初始化该用例失败");
                            }
                            logicInfo = new LogicInfo(iLogic);
                            lstLogicInfo.Add(logicInfo);
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(string.Format("加载测试逻辑失败:{0},{1}", item.FullName, ex.Message));
                        }
                    }
                }

                //绑定测试逻辑与测试集合
                BindLogicAndCluster();
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("LoadTestCase(string fileName): 加载失败 {0}", e.Message));
            }
        }
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="_render"></param>
        /// <param name="_info"></param>
        public IMainGameLogicState(LogicInfo ctrlInfo)
        {
            input         = ctrlInfo.input;
            threadLockObj = ctrlInfo.threadLockObj;

            lock (threadLockObj)
            {   // boardInfoはマルチスレッドで非同期にアクセスするので内部のnew割り当てはlockする必要がある
                boardInfo = new BoardInfo();
                scoreInfo = new ScoreInfo();
            }
        }
Example #5
0
        /// <summary>
        /// 通过用例编号链表来输出应该绑定的测试逻辑与测试集
        /// </summary>
        /// <param name="lstCaseNo"></param>
        /// <param name="lstTestCluster"></param>
        /// <param name="lstRunLogic"></param>
        private void GetCurrNeedRunTestCluster(List <string> lstCaseNo, out List <ITestCluster> lstTestCluster, out List <LogicInfo> lstRunLogic)
        {
            lstTestCluster = new List <ITestCluster>();
            lstRunLogic    = new List <LogicInfo>();

            //遍历所有的用例名
            foreach (var caseNo in lstCaseNo)
            {
                LogicInfo logicInfo = null;
                try
                {
                    //查找是否包含用例编号的逻辑
                    logicInfo = this.lstLogicInfo.FirstOrDefault((logicInfoSrc) =>
                    {
                        return(logicInfoSrc.logic.Data().FirstOrDefault(data =>
                        {
                            return this.GetDictValue(data, "用例编号").Equals(caseNo);
                        }) != null);
                    });

                    //没有找到该用例编号的逻辑则实例化并绑定到测试逻辑链表
                    if (logicInfo != null)
                    {
                        //将逻辑添加到逻辑列表中
                        if (lstRunLogic.FirstOrDefault <LogicInfo>(src => { return(src.logic.GetType().FullName.Equals(logicInfo.logic.GetType().FullName)); }) == null)
                        {
                            lstRunLogic.Add(logicInfo);
                            //添加测试逻辑
                            var testCluster = lstTestCluster.FirstOrDefault <ITestCluster>(src =>
                            {
                                return(src.GetType().FullName.Equals(logicInfo.logic.TestClusterType.FullName));
                            });

                            //未找到该测试集则加入需要绑定的测试集链表中
                            if (testCluster == null)
                            {
                                lstTestCluster.Add(logicInfo.logic.iTestCluster);
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("未找到该测试用例编号");
                    }
                }
                catch (Exception ex)
                {
                    //一般这里是不会有错的,如果有错误则在之前的绑定那一步就报错了.
                    throw new Exception(string.Format("GetCurrNeedRunTestCluster: {0}", ex.Message));
                }
            }
        }
Example #6
0
        /// <summary>
        /// 加载所选的测试逻辑(debug模式)
        /// </summary>
        /// <param name="arrILogic"></param>
        public void LoadTestCase(params ILogic[] arrILogic)
        {
            lstLogicInfo.Clear();
            this.logicFileName = string.Empty;
            //在debug模式下不需要从程序集中加载测试逻辑
            this.asmPlugin = null;

            //遍历所有的测试逻辑添加到测试逻辑链表
            foreach (var iLogic in arrILogic)
            {
                //如果该测试逻辑为null则跳过
                if (iLogic == null)
                {
                    continue;
                }

                //从测试逻辑中加载所属的逻辑文件与程序集
                this.logicFileName = string.IsNullOrEmpty(this.logicFileName) ? iLogic.GetType().FullName : this.logicFileName;
                this.asmPlugin     = this.asmPlugin == null ? iLogic.CurrAssembly : this.asmPlugin;

                //如果有相同的测试逻辑时则跳过不作处理
                var logicInfo = lstLogicInfo.FirstOrDefault <LogicInfo>(src =>
                {
                    return(src.logic.GetType().FullName.Equals(iLogic.GetType().FullName));
                });

                //在测试逻辑链表中未能找到该测试数据则进行实例化处理
                if (logicInfo == null)
                {
                    logicInfo = new LogicInfo(iLogic);
                    lstLogicInfo.Add(logicInfo);
                }
            }

            //绑定测试逻辑与测试集合
            BindLogicAndCluster();
        }