Ejemplo n.º 1
0
        public CefMessage(
            DateTimeOffset startTime,
            string hostName,
            string deviceVendor,
            string deviceProduct,
            string deviceVersion,
            int deviceEventClassId,
            string name,
            CefSeverity severity)
        {
            Extensions = new Extensions {
                StartTime = startTime, SourceHostName = hostName
            };
            DeviceVendor       = deviceVendor;
            DeviceProduct      = deviceProduct;
            DeviceVersion      = deviceVersion;
            DeviceEventClassId = deviceEventClassId;
            Name     = name;
            Severity = severity;
            HostName = hostName;

            var result = RulesValidator.Validate(new CefMessageRule(), this);

            if (!result.IsValid)
            {
                throw new CefMessageValidationException(result.Results.ToErrorsString());
            }
        }
        public void ValidateUnitTest()
        {
            Config config = new Config();

            config.Load("unit_test_config.xml");
            // MaxAgeRule validation
            Assert.IsTrue(RulesValidator.Validate(config.Bundles["0"].Rules, 15, false, 0, null));
            Assert.IsFalse(RulesValidator.Validate(config.Bundles["0"].Rules, 18, false, 0, null));
            // MinAgeRule and StudentRule validation
            Assert.IsTrue(RulesValidator.Validate(config.Bundles["1"].Rules, 18, true, 0, null));
            Assert.IsTrue(RulesValidator.Validate(config.Bundles["1"].Rules, 25, true, 12000, null));
            Assert.IsFalse(RulesValidator.Validate(config.Bundles["1"].Rules, 17, true, 12000, null));
            Assert.IsFalse(RulesValidator.Validate(config.Bundles["1"].Rules, 18, false, 12000, null));
            // MinAgeRule and MinIncomeRule validation
            Assert.IsTrue(RulesValidator.Validate(config.Bundles["2"].Rules, 18, false, 5000, null));
            Assert.IsTrue(RulesValidator.Validate(config.Bundles["2"].Rules, 25, true, 5000, null));
            Assert.IsFalse(RulesValidator.Validate(config.Bundles["2"].Rules, 25, true, 0, null));
            Assert.IsFalse(RulesValidator.Validate(config.Bundles["2"].Rules, 17, false, 10000, null));
            // IncludeOneOfProductRule validation
            List <string> products = new List <string>();

            products.Add("2");
            products.Add("3");
            products.Add("4");
            Assert.IsTrue(RulesValidator.Validate(config.Products["3"].Rules, 22, false, 21000, products));
            products.RemoveAt(1);
            Assert.IsFalse(RulesValidator.Validate(config.Products["3"].Rules, 22, false, 21000, products));
        }
Ejemplo n.º 3
0
        public Floo(string machineName)
        {
            _machineName = machineName;

            _rulesValidator = new RulesValidator(machineName);

            _stateSettingsValidator = new StateSettingsValidator(machineName);
        }
Ejemplo n.º 4
0
        public void ParseInputData_AddressWayNumberEquals0_ReturnResultCodeEquals1()
        {
            Address   address   = MockData.SetIncorrectWayNumberAddress();
            Person    person    = MockData.SetCorrectPerson();
            InputData inputData = new InputData()
            {
                AddressData = address, PersonData = person
            };

            RulesValidator <InputData> businessRulesValidator = new RulesValidator <InputData>(inputData);
            AddressRules <InputData>   addressRules           = new AddressRules <InputData>();
            PersonRules <InputData>    personRules            = new PersonRules <InputData>();

            businessRulesValidator.AddRules(addressRules.Rules);
            businessRulesValidator.AddRules(personRules.Rules);
            ValidationError result = businessRulesValidator.GetValidationError();

            Assert.AreEqual(result.Code, 1);
        }
Ejemplo n.º 5
0
        public void ParseInputData_NoError_ReturnNull()
        {
            Address   address   = MockData.SetCorrectAddress();
            Person    person    = MockData.SetCorrectPerson();
            InputData inputData = new InputData()
            {
                AddressData = address, PersonData = person
            };

            RulesValidator <InputData> businessRulesValidator = new RulesValidator <InputData>(inputData);
            AddressRules <InputData>   addressRules           = new AddressRules <InputData>();
            PersonRules <InputData>    personRules            = new PersonRules <InputData>();

            businessRulesValidator.AddRules(addressRules.Rules);
            businessRulesValidator.AddRules(personRules.Rules);
            ValidationError result = businessRulesValidator.GetValidationError();

            Assert.IsNull(result);
        }
Ejemplo n.º 6
0
        public void ParseInputData_AddressAndPersonAreIncorrect_ReturnListOfValidationError()
        {
            Address   address   = MockData.SetIncorrectWayNumberAndWayNameAddress();
            Person    person    = MockData.SetIncorrectFirstNameLastNamePerson();
            InputData inputData = new InputData()
            {
                AddressData = address, PersonData = person
            };

            RulesValidator <InputData> businessRulesValidator = new RulesValidator <InputData>(inputData);
            AddressRules <InputData>   addressRules           = new AddressRules <InputData>();
            PersonRules <InputData>    personRules            = new PersonRules <InputData>();


            businessRulesValidator.AddRules(addressRules.Rules);
            businessRulesValidator.AddRules(personRules.Rules);
            List <ValidationError> result = businessRulesValidator.GetValidationErrors();

            Assert.AreEqual(result.Count, 4);
        }
Ejemplo n.º 7
0
        public void ParseInputData_AddressWayNumberEquals0AndSkipResultCode1_ReturnNull()
        {
            Address   address   = MockData.SetIncorrectWayNumberAddress();
            Person    person    = MockData.SetCorrectPerson();
            InputData inputData = new InputData()
            {
                AddressData = address, PersonData = person
            };

            RulesValidator <InputData> businessRulesValidator = new RulesValidator <InputData>(inputData);
            AddressRules <InputData>   addressRules           = new AddressRules <InputData>();
            PersonRules <InputData>    personRules            = new PersonRules <InputData>();

            List <int> rulesToSkip = new List <int>();

            rulesToSkip.Add(1);

            businessRulesValidator.AddRules(addressRules.Rules);
            businessRulesValidator.AddRules(personRules.Rules);
            ValidationError result = businessRulesValidator.GetValidationError(rulesToSkip);

            Assert.IsNull(result);
        }
        public ReconcileViewModel()
        {
            validator     = new RulesValidator();
            dialogManager = new DialogManager();
            recEqComparer = new RecordDublicateEqualityComparer();

            context = DatabaseManager.DatabaseContext;

            var unrec = from rec in context.Records
                        where rec.IsVaidated == false
                        select rec;

            UnreconciledRecords = new ObservableCollection <Record>(unrec);

            foreach (var r in UnreconciledRecords)
            {
                validator.ValidateRecord(r);
            }

            Groups1 = context.Groups1.Local;

            CheckDublicate();
        }
Ejemplo n.º 9
0
        public Floo()
        {
            _rulesValidator = new RulesValidator(string.Empty);

            _stateSettingsValidator = new StateSettingsValidator(string.Empty);
        }
Ejemplo n.º 10
0
 public ValidationResult Validate(object message)
 {
     return(RulesValidator.Validate(this, (T)message));
 }
 public ImportExportCsvManager()
 {
     context   = DatabaseManager.DatabaseContext;
     validator = new RulesValidator();
 }