Пример #1
0
        public bool Validate(string arg)
        {
            arg = arg.Trim();
            bool result = arg.ToLower() == BitMobile.ValueStack.ValueStack.VALIDATE_ALL
                ? ((IValidatable)CurrentScreen.Screen).Validate()
                : arg.Split(';').Select(item => ValueStack.Peek(item.Trim())).OfType <IValidatable>().Aggregate(true, (current, validatable) => current & validatable.Validate());

            return(result);
        }
Пример #2
0
        public static void PeekInt32Test()
        {
            var valueStack = new ValueStack <int>(new int[] { 1, 2, 3 });

            Assert.That(() => valueStack.Peek(0),
                        Is.EqualTo(3)
                        );

            valueStack.Push(4);

            Assert.That(() => valueStack.Peek(0),
                        Is.EqualTo(4)
                        );

            Assert.That(() => valueStack.Peek(3),
                        Is.EqualTo(1)
                        );

            _ = valueStack.Pop();
            valueStack.Push(5);

            Assert.That(() => valueStack.Peek(0),
                        Is.EqualTo(5)
                        );

            Assert.That(() => valueStack.Peek(1),
                        Is.EqualTo(3)
                        );

            _ = valueStack.Pop();
            valueStack.Push(6);
            valueStack.Push(7);

            Assert.That(() => valueStack.Peek(0),
                        Is.EqualTo(7)
                        );

            Assert.That(() => valueStack.Peek(2),
                        Is.EqualTo(3)
                        );

            Assert.That(() => valueStack,
                        Has.Property("Capacity").EqualTo(6)
                        .And.Count.EqualTo(5)
                        );

            valueStack = new ValueStack <int>();

            Assert.That(() => valueStack.Peek(0),
                        Throws.InstanceOf <ArgumentOutOfRangeException>()
                        .And.Property("ActualValue").EqualTo(0)
                        .And.Property("ParamName").EqualTo("index")
                        );
        }
Пример #3
0
        public static void PeekTest()
        {
            var valueStack = new ValueStack <int>(new int[] { 1, 2, 3 });

            Assert.That(() => valueStack.Peek(),
                        Is.EqualTo(3)
                        );

            valueStack.Push(4);

            Assert.That(() => valueStack.Peek(),
                        Is.EqualTo(4)
                        );

            _ = valueStack.Pop();
            valueStack.Push(5);

            Assert.That(() => valueStack.Peek(),
                        Is.EqualTo(5)
                        );

            _ = valueStack.Pop();
            valueStack.Push(6);
            valueStack.Push(7);

            Assert.That(() => valueStack.Peek(),
                        Is.EqualTo(7)
                        );

            Assert.That(() => valueStack,
                        Has.Property("Capacity").EqualTo(6)
                        .And.Count.EqualTo(5)
                        );

            valueStack = new ValueStack <int>();

            Assert.That(() => valueStack.Peek(),
                        Throws.InvalidOperationException
                        );
        }
Пример #4
0
        private void ExecuteVerify()
        {
            Contract.Ensures(Contract.OldValue(ToBool(ValueStack.Peek())) &&
                             ValueStack.Count == Contract.OldValue(ValueStack.Count) - 1 &&
                             Contract.OldValue(HardFailure) == HardFailure ||
                             !Contract.OldValue(ToBool(ValueStack.Peek())) &&
                             ValueStack.Count == Contract.OldValue(ValueStack.Count) &&
                             HardFailure == true &&
                             ByteArrayComparer.Instance.Compare(ValueStack.Peek(), Contract.OldValue(ValueStack.Peek())) == 0);
            var valid = ToBool(ValueStack.Peek());

            if (valid)
            {
                ValueStack.Pop();
            }
            else
            {
                HardFailure = true;
            }
        }
Пример #5
0
        public bool Validate(string args)
        {
            bool result;

            args = args.Trim();
            if (args.ToLower() == BitMobile.ValueStack.ValueStack.VALIDATE_ALL)
            {
                result = ((IValidatable)CurrentScreen.Screen).Validate();
            }
            else
            {
                result = true;
                foreach (var item in args.Split(';'))
                {
                    IValidatable validatable = ValueStack.Peek(item.Trim()) as IValidatable;
                    if (validatable != null)
                    {
                        result &= validatable.Validate();
                    }
                }
            }

            return(result);
        }
Пример #6
0
        public bool Validate(string args)
        {
            bool result;

            args = args.Trim();
            if (args.ToLower() == ValueStackConst.ValidateAll)
            {
                result = RootControl.Validate();
            }
            else
            {
                result = true;
                foreach (string item in args.Split(';'))
                {
                    var validatable = ValueStack.Peek(item.Trim()) as IValidatable;
                    if (validatable != null)
                    {
                        result &= validatable.Validate();
                    }
                }
            }

            return(result);
        }