static CustomerModel() { firstNameRule = new SimpleRule("DataValue", "Firstname can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); lastNameRule = new SimpleRule("DataValue", "Lastname can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); emailRule = new SimpleRule("DataValue", "Email can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); homePhoneNumberRule = new SimpleRule("DataValue", "HomePhoneNumber can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); address1Rule = new SimpleRule("DataValue", "Address1 can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); address2Rule = new SimpleRule("DataValue", "Address2 can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); address3Rule = new SimpleRule("DataValue", "Address3 can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); }
public void CreateSimpleSensorWithInformationSource_NormalData_ProcessMessageCorrectly() { //arrange var informationSource = new SimpleInformationSource(); var netEvenTArgs = new NetworkEventArgs(string.Empty, 0, string.Empty, 0, "hacking attempt", DateTime.Now, Guid.NewGuid()); var netEvenTArgs2 = new NetworkEventArgs(string.Empty, 0, string.Empty, 0, "hello", DateTime.Now, Guid.NewGuid()); var netEvenTArgs3 = new NetworkEventArgs(string.Empty, 0, string.Empty, 0, "hello", DateTime.Now, Guid.NewGuid()); informationSource.AddNetworkMessage(netEvenTArgs); informationSource.AddNetworkMessage(netEvenTArgs2); informationSource.AddNetworkMessage(netEvenTArgs3); SimpleRule rule = new SimpleRule("hacking attempt"); var sensor = new Sensor(informationSource, rule); //act bool result = sensor.ProcessNextMessage(); //assert Assert.AreEqual(true, result); Assert.AreEqual(2, sensor.UnreadBufferCount); }
/// <summary> /// Static Constructor that defines the validation rules /// </summary> static LoginViewViewModel() { UserNameCannnotBeEmptyRule = new SimpleRule("DataValue", "Username cannot be blank", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); PasswordCannotBeEmptyRule = new SimpleRule("DataValue", "Password cannot be blank", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); SelectedBusinessUnitCannotBeEmpty = new SimpleRule("DataValue", "Please select a BU", (Object domainObject) => { DataWrapper <Int32> obj = (DataWrapper <Int32>)domainObject; return(obj.DataValue.CompareTo(null) != 0); }); }
static User() { UserNameCannotBeEmptyRule = new SimpleRule("DataValue", "User Name can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); PasswordCannotBeEmptyRule = new SimpleRule("DataValue", "Password can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); ConfrimPasswordCannotBeEmptyRule = new SimpleRule("DataValue", "Confirm Password can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); ConfirmPasswordAndPasswordMustBeEqualRule = new SimpleRule("DataValue", "Confirm Password must equal Password", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.Compare(obj.DataValue, password.DataValue, StringComparison.Ordinal) != 0); }); StatusCannotBeEmptyRule = new SimpleRule("DataValue", "Status can not be empty", (Object domainObject) => { DataWrapper <Status> obj = (DataWrapper <Status>)domainObject; return(obj.DataValue.Equals(null)); }); JobTitleCannotBeEmpyRule = new SimpleRule("DataValue", "Job Title can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); FirstNameCannotBeEmptyRule = new SimpleRule("DataValue", "First Name can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); LastNameCannotBeEmptyRule = new SimpleRule("DataValue", "Last Name can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); //DateOfBirthCannotBeNullRule = new SimpleRule("DataValue", "Date of birth can not be empty", // (Object domainObject) => // { //DataWrapper<DateTime> obj = (DataWrapper<DateTime>)domainObject; //return String.IsNullOrEmpty(obj.DataValue.ToString(CultureInfo.InvariantCulture)); // }); DateOfBirthMustBeAValidDate = new SimpleRule("DataValue", "Date of birth must be a valid date", (Object domainObject) => { DataWrapper <DateTime> obj = (DataWrapper <DateTime>)domainObject; DateTime dt; return(!DateTime.TryParse(obj.DataValue.ToString(CultureInfo.InvariantCulture), out dt)); }); EmailAddressMustBeInCorrectFormat = new SimpleRule("DataValue", "Email Address must be in correct format", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; if (obj.DataValue != null) { Regex re = new Regex(@"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*" + "@" + @"((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$", RegexOptions.IgnoreCase); return(!re.IsMatch(obj.DataValue.ToLower())); } else { return(true); } }); }
static User() { UserNameCannotBeEmptyRule = new SimpleRule("DataValue", "User Name can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); PasswordCannotBeEmptyRule = new SimpleRule("DataValue", "Password can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); ConfrimPasswordCannotBeEmptyRule = new SimpleRule("DataValue", "Confirm Password can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); ConfirmPasswordAndPasswordMustBeEqualRule = new SimpleRule("DataValue", "Confirm Password must equal Password", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.Compare(obj.DataValue, password.DataValue, StringComparison.Ordinal) != 0); }); StatusCannotBeEmptyRule = new SimpleRule("DataValue", "Status can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); JobTitleCannotBeEmpyRule = new SimpleRule("DataValue", "Job Title can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); FirstNameCannotBeEmptyRule = new SimpleRule("DataValue", "First Name can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); LastNameCannotBeEmptyRule = new SimpleRule("DataValue", "Last Name can not be empty", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; return(String.IsNullOrEmpty(obj.DataValue)); }); EmailAddressMustBeInCorrectFormat = new SimpleRule("DataValue", "Email Address must be in correct format", (Object domainObject) => { DataWrapper <String> obj = (DataWrapper <String>)domainObject; if (obj.DataValue != null) { Regex re = new Regex(@"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*" + "@" + @"((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$", RegexOptions.IgnoreCase); return(!re.IsMatch(obj.DataValue.ToLower())); } else { return(true); } }); }
public static Department WithSimpleRule(int number, SimpleRule simpleRule) { return(new Department(number, simpleRule)); }
public OffnetConditionalServiceRule(string partnerTag, SimpleRule condition, OffnetServiceMappingRule r) { _partnerTag = partnerTag; _condition = condition; _rule = r; }