コード例 #1
0
        private OutputParameter CheckInput(Parameter parameter, VerifyerParameter verifyerParameter)
        {
            if (verifyerParameter.Direction == RatchetingDirections.TowardsZero)
            {
                _checker = new TowardsZeroChecker();
            }
            else
            {
                _checker = new TowardsHundredChecker();
            }
            _logProxy.LogThis(MessageImportance.Low, string.Format("Checking {0}", parameter.ParameterName));
            var par = new OutputParameter(parameter.ParameterName, "", false);

            if (Checker.CurrentValueIsWorseThanTargetValue(parameter.CurrentValue, verifyerParameter.TargetValue))
            {
                par.IsOk          = false;
                par.VeriferResult = string.Format("Fail: {0} -> Current value is worse than target",
                                                  parameter.ParameterName);
                return(par);
            }
            if (Checker.CurrentValueIsEqualToTargetValue(parameter.CurrentValue, verifyerParameter.TargetValue))
            {
                par.IsOk          = true;
                par.VeriferResult = string.Format(
                    "Warning: {0} -> Current and Target equal - you are close to fail",
                    parameter.ParameterName);
                return(par);
            }
            if (Checker.CurrentValueIsBetterThanTargetValue(parameter.CurrentValue, verifyerParameter.TargetValue) &
                !Checker.CurrentValueIsBetterThanTargetValueAndWarning(parameter.CurrentValue,
                                                                       verifyerParameter.TargetValue,
                                                                       verifyerParameter.WarningValue))
            {
                par.IsOk          = true;
                par.VeriferResult = string.Format(
                    "Warning: {0} -> Current better than target but within warning - you are close to fail",
                    parameter.ParameterName);
                return(par);
            }
            if (Checker.CurrentValueIsBetterThanTargetValue(parameter.CurrentValue, verifyerParameter.TargetValue) && verifyerParameter.RatchetValue > 0)
            {
                par.IsOk          = true;
                par.VeriferResult = string.Format("Success: {0} -> Current is better than Target and can be ratcheted to {1}",
                                                  parameter.ParameterName,
                                                  Checker.NewRatchetValue(verifyerParameter.TargetValue,
                                                                          verifyerParameter.RatchetValue));
                return(par);
            }

            if (Checker.CurrentValueIsBetterThanTargetValue(parameter.CurrentValue, verifyerParameter.TargetValue))
            {
                par.IsOk          = true;
                par.VeriferResult = string.Format("Success: {0} -> Current is better than Target", parameter.ParameterName);
                return(par);
            }

            par.IsOk          = false;
            par.VeriferResult = "Error in verification: somehow i didn't  foresee this";
            return(par);
        }
コード例 #2
0
 public bool CheckDirectInput(Parameter parameter, VerifyerParameter verifyerParameter)
 {
     if (IsSameParameterName(parameter, verifyerParameter))
     {
         var result = CheckInput(parameter, verifyerParameter);
         _logProxy.LogThis(MessageImportance.Normal, result.VeriferResult);
         return(result.IsOk);
     }
     _logProxy.LogThis(MessageImportance.Normal,
                       string.Format("Warning: no comparison due to differing parameternames {0} <-> {1}",
                                     parameter.ParameterName, verifyerParameter.ParameterName));
     return(false);
 }
コード例 #3
0
        private bool IsSameParameterName(Parameter parameter, VerifyerParameter verifyerParameter)
        {
            if (string.IsNullOrEmpty(parameter.ParameterName) & string.IsNullOrEmpty(verifyerParameter.ParameterName))
            {
                return(true);
            }
            if (string.IsNullOrEmpty(parameter.ParameterName) || string.IsNullOrEmpty(verifyerParameter.ParameterName))
            {
                return(false);
            }
            if (parameter.ParameterName.ToLower( ) == verifyerParameter.ParameterName.ToLower( ))
            {
                return(true);
            }

            return(false);
        }
コード例 #4
0
        public override bool Execute()
        {
            MyLogger.LogThis(MessageImportance.Low, "ratchet: started!");

            //verify properties
            var  verifyer = new Verifyer(MyLogger);
            bool result   = false;

            switch (MyInputType)
            {
            case InputTypes.Direct:
                Parameter         parameter         = CreateParameter();
                VerifyerParameter verifyerParameter = CreateVerifyParameter();
                result = verifyer.CheckDirectInput(parameter, verifyerParameter);
                break;

            case InputTypes.DirectVsFile:
                //todo: enable when xmlhandler is done, and write a integrationtest
                //var validateXML = new XmlValidator(MyLogger);
                //if (!validateXML.ValidateXml(TargetFilePath, @"..\..\..\Ratcheter\files\testFile.xsd"))
                //{
                //    return false;
                //}
                //Parameter directParameter = CreateParameter();
                //List<VerifyerParameter> list = MyXmlHandler.ReadVerifyerParametersFromFile(TargetFilePath);
                //List<OutputParameter> outPutList = (List<OutputParameter>)verifyer.CheckDirectVsParameterList(directParameter, list);
                //MyXmlHandler.WriteOutputParametersToFile(ResultFilePath, outPutList);
                //var t = outPutList.Find(x => x.IsOk == false);
                //if (t != null)
                //    return false;
                break;

            case InputTypes.FileVsFile:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            //read xml
            //iterate through objectlist
            //write and log


            return(result);
        }