Пример #1
0
        public void ValidateIsNotNullTest()
        {
            var model = new ModelFixture <string>
            {
                Value = "192.168.1.0"
            };

            model.Validator = new Action <IObservableClass>(arg =>
            {
                var i = arg as ModelFixture <string>;

                if (string.IsNullOrEmpty(i.Value))
                {
                    i.Properties[nameof(i.Value)].Errors.Add("Value is null");
                }
            });

            Assert.IsTrue(model.Validate());
        }
Пример #2
0
        public void ValidateIsInRangeTest()
        {
            var model = new ModelFixture <int>
            {
                Value = 80
            };

            model.Validator = new Action <IObservableClass>(arg =>
            {
                var i = arg as ModelFixture <int>;

                if (!Enumerable.Range(1, 500).Contains(i.Value))
                {
                    i.Properties[nameof(i.Value)].Errors.Add("Portnumber is not in range [1,100]");
                }
            });

            Assert.IsTrue(model.Validate());
        }
Пример #3
0
        public void ValidateStringLengthIsInRangeTest()
        {
            var model = new ModelFixture <string>
            {
                Value = "192.168.1.0"
            };

            model.Validator = new Action <IObservableClass>(arg =>
            {
                var i = arg as ModelFixture <string>;

                if (!Enumerable.Range(1, 35).Contains(i.Value.Length))
                {
                    i.Properties[nameof(i.Value)].Errors.Add("String should have length of 1-35 characters");
                }
            });

            Assert.IsTrue(model.Validate());
        }