public void Test()
        {
            LxLog.Init(new UnityLog());

            Container container = new Container();

            container.InitComponentComparers();
            container.SetPlayerDatabase(MatchmakingTest.TestPlayers);
            container.MmConfig = MatchmakingTest.TestConfig;

            var createJoinRequestSystem = new CreateJoinRequestSystem(container.PlayerDatabaseSize);

            createJoinRequestSystem.Execute(container);

            LxLog.Log(container.MmConfig.ToString());

            int count = 0;

            for (int i = 0; i < container.PlayerDatabaseSize; ++i)
            {
                PlayerData playerData = container.GetPlayerData(i);
                if (!playerData.IsAvailable)
                {
                    ++count;
                }
            }

            LxLog.Log($"player info component count is {container.PlayerInfoComponentsCount} not availabe player count {count}");
            Assert.AreEqual(count, container.PlayerInfoComponentsCount);
            Assert.AreEqual(count, container.MmrComponentsCount);

            for (int i = 0; i < container.MmrComponentsCount; ++i)
            {
                if (container.TryGetMmrWeightFromIndex(i, out long weight))
                {
                    int entityId = container.GetMMrEntityId(i);
                    if (container.TryGetPlayerInfoDatabaseKeyFromEntityId(entityId, out int databaseKey))
                    {
                        PlayerData player = container.GetPlayerData(databaseKey);

                        LxLog.Log($"{player.Name} win {player.Wins} lose {player.Loses} weight {weight}");
                        JoinRequestResult result = _result[i];
                        Assert.AreEqual(result.Name, player.Name);
                        Assert.AreEqual(result.Weight, weight);
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Performs the playback of actions in this module.
        /// </summary>
        /// <remarks>You should not call this method directly, instead pass the module
        /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
        /// that will in turn invoke this method.</remarks>
        void ITestModule.Run()
        {
            Mouse.DefaultMoveTime        = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor            = 1.0;
            LxSetup mainOp  = LxSetup.getInstance();
            var     configs = mainOp.configs;

            string DetailSteps   = AppConfigOper.mainOp.getConfigValue("DetailSteps_InResult");
            string strUserName   = AppConfigOper.mainOp.getConfigValue("UserName");
            string strPassword   = AppConfigOper.mainOp.getConfigValue("Password");
            string strServerName = AppConfigOper.mainOp.getConfigValue("ServerName");

            BackupDB();

            string tsName      = mainOp.getTestCaseName();
            string excelPath   = "keywordscripts/" + tsName + ".xlsx";
            string keywordName = "keywordscripts/";

            Report.Info("INfo", excelPath);

            mainOp.StrExcelDirve = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                          excelPath);
            mainOp.m_strUserName   = strUserName;
            mainOp.m_stPassword    = strPassword;
            mainOp.m_strServerName = strServerName;

            mainOp.runApp();//  ********* 1. run Application *********

            //Copy script to Report folder
            string reportPath = Program.getReport();
            string sourcePath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                                       keywordName);

            string  reprotFileName  = reportPath + tsName + ".xlsx";
            string  sourceFileName  = mainOp.StrExcelDirve;
            LxParse stepsRepository = mainOp.getSteps();
            // stepsRepository.doValidate();                //  ********* 2. check scripts  syntax *********

            int       myProcess = mainOp.ProcessId;
            ArrayList stepList  = stepsRepository.getStepsList();
            bool      result    = true;

            //  ********* 3. run scripts with reflection *********
            try
            {
                result = LxGenericAction.performScripts(stepList, DetailSteps);
            }
            catch (Exception e)
            {
                result = false;
                LxLog.Error("Error", tsName + " " + e.Message.ToString());
            }

            mainOp.setResult();
            mainOp.runOverOneCase(tsName);
            mainOp.opXls.close();
            Delay.Seconds(5);
            LxTearDown.closeApp(mainOp.ProcessId);              //  ********* 4. clean up for next running *********

            RestoreDB();

            // Add excel file link in Ranorex.report.
            string linkFile = reportPath + tsName + ".xlsx";
            string html     = String.Format("<a href='{0}'>{1}</a>", linkFile, tsName);

            Report.LogHtml(ReportLevel.Info, "Info", html);

            //Copy all report created by Ranorex to Nform Report folder.
//          XCopy(sourcePath, reportPath);
            System.IO.File.Copy(sourceFileName, reprotFileName, true);

            if (!result)
            {
                throw new Ranorex.ValidationException("The test case running failed!", null);
            }
        }