private List <VerifyerParameter> CreateVerifyParameterList(string specialParameter, int targetValue, int ratchet, int warning, RatchetingDirections direction)
        {
            var list = CreateVerifyParameterList();

            var specPar = new VerifyerParameter(specialParameter, targetValue, ratchet, warning, direction);

            list.Add(specPar);
            return(list);
        }
Exemple #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;
 }
        public void CheckDirectInputLogsAsFailIfCurrentValueIsHigherThanTargetAndDirectionTowardsZero()
        {
            //Arrange
            var logProxy = MockRepository.GenerateMock<ILogProxy>();
            var verifyer = new Verifyer(logProxy);
            //Act
            logProxy.Expect(x => x.LogThis(MessageImportance.Normal, "Fail: para -> Current value is worse than target"));
            var parameter = new Parameter("para", 6);
            var verifyerParameter = new VerifyerParameter("para", 5, 0, 2, RatchetingDirections.TowardsZero);
            //Assert
            verifyer.CheckDirectInput(parameter,verifyerParameter );

            logProxy.VerifyAllExpectations();
        }
        public void CheckDirectInputLogsAsSuccessIfCurrentValueIsHigherThanTargetPlusWarningAndDirectionTowardsHundred()
        {
            //Arrange
            var logProxy = MockRepository.GenerateMock<ILogProxy>();
            var verifyer = new Verifyer(logProxy);
            //Act
            logProxy.Expect( x => x.LogThis(MessageImportance.Normal, "Success: para -> Current is better than Target"));
            var parameter = new Parameter("para", 6);
            var verifyerParameter = new VerifyerParameter("para", 5, 0, 0,RatchetingDirections.TowardsHundred );
            //Assert
            verifyer.CheckDirectInput(parameter,verifyerParameter );

            logProxy.VerifyAllExpectations();
        }
        public void CheckDirectInputLogsAsSuccessIfCurrentValueIslowerThanTargetPlusWarningAndDirectionTowardsZero()
        {
            //Arrange
            var logProxy = MockRepository.GenerateMock <ILogProxy>();
            var verifyer = new Verifyer(logProxy);

            logProxy.Expect(x => x.LogThis(MessageImportance.Normal, "Success: para -> Current is better than Target"));
            var parameter         = new Parameter("para", 1);
            var verifyerParameter = new VerifyerParameter("para", 5, 0, 2, RatchetingDirections.TowardsZero);

            //Act
            verifyer.CheckDirectInput(parameter, verifyerParameter);
            //Assert
            logProxy.VerifyAllExpectations();
        }
        public void CheckDirektInputWillNotSuggestRatchetBelowZero()
        {
            //Arrange
            var logProxy = MockRepository.GenerateMock <ILogProxy>();
            var verifyer = new Verifyer(logProxy);

            logProxy.Expect(x => x.LogThis(MessageImportance.Normal, "Success: para -> Current is better than Target and can be ratcheted to 0"));
            var parameter         = new Parameter("para", 1);
            var verifyerParameter = new VerifyerParameter("para", 5, 7, 2, RatchetingDirections.TowardsZero);

            //Act
            verifyer.CheckDirectInput(parameter, verifyerParameter);
            //Assert

            logProxy.VerifyAllExpectations();
        }
        public void CheckDirectInputLogsAsFailIfCurrentValueIsHigherThanTargetAndDirectionTowardsZero()
        {
            //Arrange
            var logProxy = MockRepository.GenerateMock <ILogProxy>();
            var verifyer = new Verifyer(logProxy);

            //Act
            logProxy.Expect(x => x.LogThis(MessageImportance.Normal, "Fail: para -> Current value is worse than target"));
            var parameter         = new Parameter("para", 6);
            var verifyerParameter = new VerifyerParameter("para", 5, 0, 2, RatchetingDirections.TowardsZero);

            //Assert
            verifyer.CheckDirectInput(parameter, verifyerParameter);

            logProxy.VerifyAllExpectations();
        }
        public void AVerifyerParameterIsTheVerifyerValues()
        {
            //Arrange
            var name = "name";
            var targetValue = 3;
            var warning = 2;
            var ratchet = 1;
            var verpara = new VerifyerParameter(name, targetValue, ratchet, warning,RatchetingDirections.TowardsHundred );
            //Act
            Assert.AreEqual(name , verpara.ParameterName );
            Assert.AreEqual(targetValue , verpara.TargetValue );
            Assert.AreEqual(warning, verpara.WarningValue );
            Assert.AreEqual(ratchet, verpara.RatchetValue);
            Assert.AreEqual(RatchetingDirections.TowardsHundred , verpara.Direction );

            //Assert
        }
        public void WhenCurrentIsMuchBetterThanTargetItWillSuggestCurrentWith2TimesWarningAsBuffer()
        {
            //Arrange
            var logProxy = MockRepository.GenerateStrictMock <ILogProxy>();
            var verifyer = new Verifyer(logProxy);

            logProxy.Expect(x => x.LogThis(MessageImportance.Low, "Checking para"));
            logProxy.Expect(x => x.LogThis(MessageImportance.Normal, "Success: para -> Current is better than Target and can be ratcheted to 14"));
            var parameter         = new Parameter("para", 10);
            var verifyerParameter = new VerifyerParameter("para", 20, 2, 2, RatchetingDirections.TowardsZero);

            //Act
            verifyer.CheckDirectInput(parameter, verifyerParameter);
            //Assert

            logProxy.VerifyAllExpectations();
        }
        public void AVerifyerParameterIsTheVerifyerValues()
        {
            //Arrange
            var name        = "name";
            var targetValue = 3;
            var warning     = 2;
            var ratchet     = 1;
            var verpara     = new VerifyerParameter(name, targetValue, ratchet, warning, RatchetingDirections.TowardsHundred);

            //Act
            Assert.AreEqual(name, verpara.ParameterName);
            Assert.AreEqual(targetValue, verpara.TargetValue);
            Assert.AreEqual(warning, verpara.WarningValue);
            Assert.AreEqual(ratchet, verpara.RatchetValue);
            Assert.AreEqual(RatchetingDirections.TowardsHundred, verpara.Direction);


            //Assert
        }
        public void CheckDirectInputLogsAsSuccessIfCurrentValueIsHigherThanTargetbutnotWarningAndDirectionTowardsHundred()
        {
            //Arrange
            var logProxy = MockRepository.GenerateMock <ILogProxy>();
            var verifyer = new Verifyer(logProxy);

            //Act
            logProxy.Expect(
                x =>
                x.LogThis(MessageImportance.Normal,
                          "Warning: para -> Current better than target but within warning - you are close to fail"));
            //Assert
            var parameter         = new Parameter("para", 6);
            var verifyerParameter = new VerifyerParameter("para", 5, 0, 2, RatchetingDirections.TowardsHundred);

            verifyer.CheckDirectInput(parameter, verifyerParameter);

            logProxy.VerifyAllExpectations();
        }
        public void CheckDirektInputLogsAsRatchetableWhenSoIsTheCase()
        {
            // since my take around direct input is that you usually don´t use xmlfiles
            // i want it to just suggest the new value in the log and let the user handle that as he wants


            //Arrange
            var logProxy = MockRepository.GenerateMock <ILogProxy>();
            var verifyer = new Verifyer(logProxy);

            logProxy.Expect(x => x.LogThis(MessageImportance.Normal, "Success: para -> Current is better than Target and can be ratcheted to 3"));
            var parameter         = new Parameter("para", 1);
            var verifyerParameter = new VerifyerParameter("para", 5, 2, 2, RatchetingDirections.TowardsZero);

            //Act
            verifyer.CheckDirectInput(parameter, verifyerParameter);
            //Assert

            logProxy.VerifyAllExpectations();
        }
Exemple #13
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;
        }
        public void CheckDirektInputLogsAsRatchetableWhenSoIsTheCase()
        {
            // since my take around direct input is that you usually don´t use xmlfiles
            // i want it to just suggest the new value in the log and let the user handle that as he wants

            //Arrange
            var logProxy = MockRepository.GenerateMock<ILogProxy>();
            var verifyer = new Verifyer(logProxy);

            logProxy.Expect(x => x.LogThis(MessageImportance.Normal, "Success: para -> Current is better than Target and can be ratcheted to 3"));
            var parameter = new Parameter("para", 1);
            var verifyerParameter = new VerifyerParameter("para", 5, 2, 2, RatchetingDirections.TowardsZero);
            //Act
            verifyer.CheckDirectInput(parameter, verifyerParameter);
            //Assert

            logProxy.VerifyAllExpectations();
        }
        private List<VerifyerParameter> CreateVerifyParameterList(string specialParameter, int targetValue, int ratchet, int warning, RatchetingDirections direction)
        {
            var list = CreateVerifyParameterList();

            var specPar = new VerifyerParameter(specialParameter, targetValue, ratchet, warning, direction);
            list.Add(specPar);
            return list;
        }
        public void WhenCurrentIsMuchBetterThanTargetItWillSuggestCurrentWith2TimesWarningAsBuffer()
        {
            //Arrange
            var logProxy = MockRepository.GenerateStrictMock<ILogProxy>();
            var verifyer = new Verifyer(logProxy);
            logProxy.Expect(x => x.LogThis(MessageImportance.Low, "Checking para"));
            logProxy.Expect(x => x.LogThis(MessageImportance.Normal, "Success: para -> Current is better than Target and can be ratcheted to 14"));
            var parameter = new Parameter("para", 10);
            var verifyerParameter = new VerifyerParameter("para", 20, 2, 2, RatchetingDirections.TowardsZero);
            //Act
            verifyer.CheckDirectInput(parameter, verifyerParameter);
            //Assert

            logProxy.VerifyAllExpectations();
        }
        public void CheckDirektInputWillNotSuggestRatchetBelowZero()
        {
            //Arrange
            var logProxy = MockRepository.GenerateMock<ILogProxy>();
            var verifyer = new Verifyer(logProxy);

            logProxy.Expect(x => x.LogThis(MessageImportance.Normal, "Success: para -> Current is better than Target and can be ratcheted to 0"));
            var parameter = new Parameter("para", 1);
            var verifyerParameter = new VerifyerParameter("para", 5, 7, 2, RatchetingDirections.TowardsZero);
            //Act
            verifyer.CheckDirectInput(parameter, verifyerParameter);
            //Assert

            logProxy.VerifyAllExpectations();
        }
        public void CheckDirectInputLogsAsSuccessIfCurrentValueIslowerThanTargetbutnotWarningAndDirectionTowardsZero()
        {
            //Arrange
            var logProxy = MockRepository.GenerateMock<ILogProxy>();
            var verifyer = new Verifyer(logProxy);
            //Act
            logProxy.Expect(
                x =>
                x.LogThis(MessageImportance.Normal,
                          "Warning: para -> Current better than target but within warning - you are close to fail"));
            var parameter = new Parameter("para", 4);
            var verifyerParameter = new VerifyerParameter("para", 5, 0, 2, RatchetingDirections.TowardsZero);
            //Assert
            verifyer.CheckDirectInput(parameter,verifyerParameter );

            logProxy.VerifyAllExpectations();
        }
Exemple #19
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;
        }