Example #1
0
 private static void CheckArgumentNameOrSwitch(NotEmpty <string> value, string argumentName)
 {
     if (value.Value.Contains(" ") || value.Value.Contains("\""))
     {
         throw new ArgumentException(
                   $"Switch or argument name '{value.Value}' shouldn't contain spaces or quotes.", argumentName);
     }
 }
        public void NotEmptyStringConvertsToStringTest()
        {
            const string expectedValue = "test";

            var notEmptyValue = NotEmpty.Wrap(expectedValue);

            Assert.AreEqual(expectedValue, notEmptyValue.ToString());
        }
        public void NotEmptyStringCastsImplicitlyToStringTest()
        {
            const string expectedValue = "test";

            var    notEmptyValue = NotEmpty.Wrap(expectedValue);
            string actualValue   = notEmptyValue;

            Assert.AreEqual(expectedValue, actualValue);
        }
        public void NotEmptyStringTest()
        {
            var expected = "Test";

            var notEmptyString = NotEmpty <string> .Create(expected);

            Assert.IsNotNull(notEmptyString);
            Assert.AreEqual(expected, notEmptyString.Value);
        }
        public void NotEmptyStringFailsOnWhitespaceStringTest()
        {
            var exception = Assert.Throws <ArgumentException>
                            (
                () => { NotEmpty.Wrap(" "); }
                            );

            Assert.AreEqual(@"value", exception.ParamName);
        }
        public void NotEmptyStringFailsOnNullStringTest()
        {
            var exception = Assert.Throws <ArgumentNullException>
                            (
                () => { NotEmpty.Wrap(null); }
                            );

            Assert.AreEqual(@"value", exception.ParamName);
        }
Example #7
0
 public static IOption <NotEmpty <string> > CreateNotEmpty(string text)
 {
     if (text != "")
     {
         NotEmpty <string> notEmpty = new NotEmpty <string>(text);
         return(Option.Some(notEmpty));
     }
     return(Option.None <NotEmpty <string> >());
 }
Example #8
0
        static IValidator NotEmpty(object pValue, string pFieldName, string pErrorMsg)
        {
            IValidator validator = new NotEmpty()
            {
                Value     = pValue,
                FieldName = pFieldName,
                ErrorMsg  = pErrorMsg
            };

            return(validator);
        }
Example #9
0
        public void Validate_WhenIsNotEmpty_ReturnsSuccess(string value)
        {
            //Given
            var validator = new NotEmpty();

            //When
            var config = new FieldConfigBuilder().Build();
            var result = validator.Validate(value, 0, config);

            //Then
            result.IsValid.Should().BeTrue();
        }
Example #10
0
        public void Validate_WhenTypeIsNotStringOrHasValue_ReturnsSuccess(object obj)
        {
            //Given
            var validator = new NotEmpty();

            //When
            var config = new FieldConfigBuilder().Build();
            var result = validator.Validate(obj, 0, config);

            //Then
            result.IsValid.Should().BeTrue();
        }
Example #11
0
        public void Validate_WhenIsEmptyOrWhiteSpaces_ReturnsError(string value)
        {
            ///Given
            var validator = new NotEmpty();

            //When
            var config = new FieldConfigBuilder().Build();
            var result = validator.Validate(value, 0, config);

            //Then
            result.IsValid.Should().BeFalse();
            result.Errors[0].Value.Should().Contain("should not be empty");
        }
Example #12
0
        public void CanUse_Tests(bool notEmpty, bool expected)
        {
            //Given
            var validator = new NotEmpty();

            //When
            var result = validator.CanUse(new FieldConfig {
                Validations = new ValidationOptions {
                    NotEmpty = notEmpty
                }
            });

            //Then
            result.Should().Be(expected);
        }
Example #13
0
 //[STAThread]
 private void Run()
 {
     while (isRun)
     {
         try
         {
             int count = recycle.Items().Count;
             if (count != 0)
             {
                 NotEmpty?.Invoke();
             }
             else
             {
                 Empty?.Invoke();
             }
         }
         catch (Exception ex)
         {
             //MessageBox.Show(ex.Message);
         }
         Thread.Sleep(10);
     }
 }
Example #14
0
 public void SetUp()
 {
     _function = new NotEmpty();
 }