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();
        }
Exemple #3
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);
        }
Exemple #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;
        }
        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();
        }
        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 FilevsFileWith5ItemsGeneratesAnOutputListWith5Items()
        {
            //Arrange
            var logProxy = MockRepository.GenerateStub<ILogProxy>();
            var verifyer = new Verifyer(logProxy);

            var parameters = CreateParameterList("towards100", 89);
            var verifyerParameters = CreateVerifyParameterList("towards100", 85, 10, 0, RatchetingDirections.TowardsHundred);
            //Act
            var resultingList = verifyer.CheckFileVsFile(parameters, verifyerParameters);
            var text = new StringBuilder().Append("resulting input: ");
            foreach (var outputParameter in resultingList)
            {
                text.Append(" \n *verifyerlog: " + outputParameter.VeriferResult );
            }
            Assert.AreEqual(5, resultingList.Count, text.ToString( ));
        }
        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 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();
        }
        public void CheckDirectVsFileWith5ItemsListReturnAnOutputlistwith1item()
        {
            //Arrange
            var logProxy = MockRepository.GenerateStub<ILogProxy>();
            var verifyer = new Verifyer(logProxy);

            var parameter = new Parameter("towards100", 90);
            var verifyerParameters = CreateVerifyParameterList("towards100", 85, 10, 0, RatchetingDirections.TowardsHundred);
            //Act
            List<OutputParameter> resultingList = (List<OutputParameter>)verifyer.CheckDirectVsParameterList(parameter, verifyerParameters);

            Assert.AreEqual(1, resultingList.Count );
        }
        public void CheckDirectVsFileInputTakesAListOfVerifyParametersAndADirectInputParameterAndStartsVerify()
        {
            //Arrange
            var logProxy = MockRepository.GenerateMock<ILogProxy>();
            var verifyer = new Verifyer(logProxy);
            logProxy.Expect(
                x =>
                x.LogThis(MessageImportance.Normal,
                          "Success: towards100 -> Current is better than Target and can be ratcheted to 95"));
            var parameter = new Parameter("towards100", 90);
            var verifyerParameters = CreateVerifyParameterList("towards100",85,10,0,RatchetingDirections.TowardsHundred );
            //Act
               List<OutputParameter> resultingList = ( List<OutputParameter>)verifyer.CheckDirectVsParameterList(parameter, verifyerParameters);
            var reesult = resultingList.FirstOrDefault(x => x.ParameterName == "towards100");
            Assert.AreEqual(true, reesult.IsOk );
            Assert.AreEqual("Success: towards100 -> Current is better than Target and can be ratcheted to 95", reesult.VeriferResult );

               // logProxy.VerifyAllExpectations();
        }