Example #1
0
        protected void WhenTestingAValidEntity()
        {
            var validEntity = new TestClass {
                Name = "Name"
            };

            _resultValid = _spec.Evaluate(validEntity);
        }
Example #2
0
        protected void WhenTestingAnInValidEntity()
        {
            var validEntity = new TestClass {
                Name = null
            };

            _resultInvalid = _spec.Evaluate(validEntity);
        }
Example #3
0
 public static string GetOutcome(this SpecResult result)
 {
     if (result.Skipped)
     {
         return("Skipped");
     }
     return(result.Success ? "Passed" : "Failed");
 }
Example #4
0
 public static CommandResult FromSpec(SpecResult specResult)
 {
     return(new CommandResult
     {
         Code = specResult.Code,
         IsSuccess = specResult.True,
         Message = specResult.Message,
     });
 }
Example #5
0
        public async Task <SpecResult> IsUserEmailUnique(string email)
        {
            if (await _db.Users.AnyAsync(x => x.Email == email))
            {
                return(SpecResult.No("EMAIL_NOT_UNIQUE", "Email пользователя не уникален"));
            }

            return(SpecResult.Yes());
        }
Example #6
0
        public async Task <SpecResult> IsUserPhoneUnique(CleanPhone phone)
        {
            if (await _db.Users.AnyAsync(x => x.Phone == phone.Clean))
            {
                return(SpecResult.No("PHONE_NOT_UNIQUE", "Номер пользователя не уникален"));
            }

            return(SpecResult.Yes());
        }
Example #7
0
 public static void Format(this SpecResult result, StringBuilder text)
 {
     text.AppendLine("---------------------------------------------------------------------");
     text.AppendLine("Result:             {0}", result.Name.FormatValue());
     text.AppendLine("Success:            {0}", result.Success.FormatValue());
     text.AppendLine("Skipped:            {0}", result.Skipped.FormatValue());
     text.AppendLine("Output:             {0}", result.Output.FormatValue());
     text.AppendLine("Time:               {0}", result.Time.FormatValue());
 }
Example #8
0
        public SpecResult CheckDataBySpec(string sn, List <KeyValuePair <string, string> > data, out string message)
        {
            message = "";
            var ret = new SpecResult {
                CompareFail = false, Pausable = false, Stopable = false
            };
            var info = GetUnitInfo(sn);

            if (info == null)
            {
                this._logger.Error("sn = " + sn + ":unit info is not exist in unit set,check data by spec fail");
                return(ret);
            }
            SpecItem[]      specArray = FetchPlans.Inst(this._param.tbiesServer).GetSpecification(info.Plan);
            List <SpecItem> failList  = new List <SpecItem>();

            foreach (var specItem in specArray)
            {
                foreach (var dataRow in data)
                {
                    if (dataRow.Key == specItem.Item)
                    {
                        if (!(double.Parse(specItem.LBound) <= double.Parse(dataRow.Value) && double.Parse(dataRow.Value) < double.Parse(specItem.UBound)))
                        {
                            message += specItem.Item;
                            failList.Add(specItem);
                        }
                    }
                }
            }

            foreach (var spec in failList)
            {
                if (spec.Type.Contains("C"))
                {
                    ret.CompareFail = true;
                }
                if (spec.Type.Contains("P"))
                {
                    ret.Pausable = true;
                }
                if (spec.Type.Contains("S"))
                {
                    ret.Stopable = true;
                }
            }
            return(ret);
        }
Example #9
0
        public void DealWithSpecResult(string sn, SpecResult specResult, string message, out bool doStop)
        {
            doStop = false;
            var info = GetUnitInfo(sn);

            if (info == null)
            {
                this._logger.Error("sn = " + sn + ":unit info is not exist in unit set,deal with spec result fail");
                return;
            }

            if (specResult.CompareFail)
            {
                this._logger.Warn(sn + " COMP PARA FAIL:" + message);
                UpdateUnitResult(sn, UnitResult.FAIL, "Out OF SPEC:" + message);
            }
            if (specResult.Stopable)
            {
                this._logger.Warn(sn + " KEY PARA FAIL:" + message);
                this._logger.Warn(sn + " Try to Stop.");
                UpdateUnitResult(sn, UnitResult.FAIL, "Out OF SPEC:" + message);
                UpdateUnitState(sn, UnitState.DONE);
                doStop = true;
            }
            if (specResult.Pausable)
            {
                this._logger.Warn(sn + " COND PARA FAIL:" + message);
                if (info.OutSpec == true)
                {
                    double timeOut = this._param.conditionTimeout;// double.Parse(SettingsReader.GetInstance().GetSettingsValue("OtherSetting", "Condition_Timeout"));
                    if (DateTime.Now.Subtract(info.OutStart).TotalMinutes > timeOut)
                    {
                        UpdateUnitState(sn, UnitState.PAUSE);
                        doStop = true;
                    }
                }
                else
                {
                    info.OutSpec  = true;
                    info.OutStart = DateTime.Now;
                }
            }
            else
            {
                info.OutSpec = false;
            }
        }
Example #10
0
        private void Save_And_Check_Data(string boardName, string sn, Dictionary <int, List <KeyValuePair <string, string> > > data)
        {
            string board;
            int    seat;
            var    boardUnit = this._boardManager.GetBoardUnit(boardName);

            if (boardUnit != null)
            {
                boardUnit.GetBoardSeat(sn, out board, out seat);
                var dataSet = data[seat];
                try
                {
                    boardUnit.UpdateParaTime(sn);
                    boardUnit.UploadData(sn, dataSet);
                    string     message = "";
                    SpecResult ret     = boardUnit.CheckDataBySpec(sn, dataSet, out message);
                    bool       doStop;
                    boardUnit.DealWithSpecResult(sn, ret, message, out doStop);
                    if (doStop)
                    {
                        IBoard controller = boardUnit.GetController();
                        if (controller != null)
                        {
                            controller.CatchException(seat);
                        }
                        else
                        {
                            this._logger.Warn(sn + " stop fail ");
                        }
                    }

                    //if (ret.Stopable)
                    //{
                    //    if (this._configParam.mesParam.mesCheck)
                    //    {
                    //        //Add for MES function, defause values "", if value not null, no need the MES function
                    //        if (this._configParam.mesParam.mesHoldFlag)
                    //        {
                    //            try
                    //            {
                    //                string retMsg = "";
                    //                if (this._mesOperator.Hold(sn, "NG Auto Hold", out retMsg))
                    //                {
                    //                    this._logger.Info("The " + sn + " Auto Hold in this station.");
                    //                }
                    //                else
                    //                {
                    //                    this._logger.Warn(sn + " Fail to Hold.Reason is " + retMsg);
                    //                }
                    //            }
                    //            catch
                    //            {
                    //                this._logger.Warn(sn + " Fail to Hold for MES reason.");
                    //            };
                    //        }
                    //        else
                    //        {
                    //            this._logger.Info("The " + sn + " user no need to hold.");
                    //        }
                    //    }
                    //    else
                    //    {
                    //        this._logger.Info("The " + sn + " no need to check MES Action.");
                    //    }
                    //}
                }
                catch (Exception ex)
                {
                    this._logger.Error(sn + ":" + ex.Message);
                }
            }
        }
Example #11
0
 public async Task <SpecResult> IsUserCodeCorrect(CleanPhone phone, string code)
 {
     return(SpecResult.No("INVALID_CODE", "Код неверен"));
 }
 public void AddSpecResult(SpecResult result)
 {
     children.Add(result);
 }
Example #13
0
        private void Save_And_Check_Data(string sn, Dictionary <int, List <KeyValuePair <string, string> > > data)
        {
            string board;
            int    seat;

            unitManager.GetBoardSeat(sn, out board, out seat);
            var dataSet = data[seat];

            try
            {
                unitManager.UpdateParaTime(sn);
                unitManager.UploadData(sn, dataSet);
                string     message = "";
                SpecResult ret     = unitManager.CheckDataBySpec(sn, dataSet, out message);
                bool       doStop;
                unitManager.DealWithSpecResult(sn, ret, message, out doStop);
                IBoard controller = boardManager.GetBoardInfo(board).GetController();
                if (controller == null)
                {
                    log.Warn(sn + " stop fail ");
                }
                else
                {
                    if (doStop)
                    {
                        controller.CatchException(seat);
                    }
                    if (ret.Stopable)
                    {
                        if (controller.IsMesCheck())
                        {
                            //Add for MES function, defause values "", if value not null, no need the MES function
                            if (controller.IsHold())
                            {
                                try
                                {
                                    string retMsg = "";
                                    if (_mesOperator.Hold(sn, "NG Auto Hold", out retMsg))
                                    {
                                        log.Info("The " + sn + " Auto Hold in this station.");
                                    }
                                    else
                                    {
                                        log.Warn(sn + " Fail to Hold.Reason is " + retMsg);
                                    }
                                }
                                catch
                                {
                                    log.Warn(sn + " Fail to Hold for MES reason.");
                                };
                            }
                            else
                            {
                                log.Info("The " + sn + " user no need to hold.");
                            }
                        }
                        else
                        {
                            log.Info("The " + sn + " no need to check MES Action.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(sn + ":" + ex.Message);
            }
        }