Esempio n. 1
0
        public void Option_Handler_ChecksThatTheNumerOfArgumentsNotMoreThan2WhenWantsArgIsYes()
        {
            Option    option1 = new Option("myname_");
            CallScope scope   = new CallScope(new EmptyScope());

            scope.PushFront(Value.Get(true));
            scope.PushFront(Value.Get(true));
            scope.PushFront(Value.Get(true));
            Assert.AreEqual(3, scope.Size);
            option1.Handler(scope);
        }
Esempio n. 2
0
        public void CallScope_PushFront_AddsItemsToFirstPosition()
        {
            CallScope callScope = new CallScope(new MockScope());

            callScope.PushFront(Value.Get(11));
            callScope.PushFront(Value.Get(22));
            callScope.PushFront(Value.Get(33));

            Assert.Equal(33, callScope.Args.AsSequence[0].AsLong);
            Assert.Equal(22, callScope.Args.AsSequence[1].AsLong);
            Assert.Equal(11, callScope.Args.AsSequence[2].AsLong);
        }
Esempio n. 3
0
        public void Option_Handler_CallsOnWithOneArgumentIfWantsArgIsNo()
        {
            Option    option1 = new Option("myname");
            CallScope scope1  = new CallScope(new EmptyScope());

            scope1.PushFront(Value.Get("whence"));
            option1.Handler(scope1);
            Assert.IsTrue(option1.Handled);
        }
Esempio n. 4
0
        public void Option_Handler_ChecksThatTheNumerOfArgumentsNotLessThan2WhenWantsArgIsYes()
        {
            Option    option1 = new Option("myname_");
            CallScope scope   = new CallScope(new EmptyScope());

            scope.PushFront(Value.Get(true));
            Assert.Equal(1, scope.Size);
            Assert.Throws <InvalidOperationException>(() => option1.Handler(scope));
        }
Esempio n. 5
0
        public void CallScope_Resolve_DoesNotCalculateNonAnyValues()
        {
            CallScope callScope = new CallScope(new MockScope());
            callScope.PushFront(Value.Get(33));

            Value result = callScope.Resolve(0);

            Assert.Equal(33, result.AsLong);
        }
Esempio n. 6
0
        public void Option_Handler_CallsReturnsTrueValue()
        {
            Option    option1 = new Option("myname");
            CallScope scope1  = new CallScope(new EmptyScope());

            scope1.PushFront(Value.Get("whence"));
            Value val = option1.Handler(scope1);

            Assert.IsTrue(val.AsBoolean);
        }
Esempio n. 7
0
        public void CallScope_Resolve_CallsAnyValuesAsExpr()
        {
            CallScope callScope = new CallScope(new MockScope());
            ExprOp testExprOp = new ExprOp(OpKindEnum.VALUE) { AsValue = Value.Get(55) };
            callScope.PushFront(Value.Get(testExprOp));

            Value result = callScope.Resolve(0, ValueTypeEnum.Integer, true);

            Assert.Equal(55, result.AsLong);
        }
Esempio n. 8
0
        public void Option_Handler_CallsOnWithTwoArgumentsIfWantsArgIsYes()
        {
            Option    option1 = new Option("myname_");
            CallScope scope1  = new CallScope(new EmptyScope());

            scope1.PushFront(Value.Get("whence"));
            scope1.PushBack(Value.Get("str"));
            option1.Handler(scope1);
            Assert.AreEqual("str", option1.Value);
            Assert.IsTrue(option1.Handled);
        }
Esempio n. 9
0
        public void CallScope_Value_ThisIsEqualToResolve()
        {
            CallScope callScope = new CallScope(new MockScope());

            ExprOp testExprOp = new ExprOp(OpKindEnum.VALUE) { AsValue = Value.Get(55) };
            callScope.PushFront(Value.Get(testExprOp));

            Value result = callScope[0];

            Assert.Equal(55, result.AsLong);
        }
Esempio n. 10
0
        public void CallScope_Value_MakesSureThatAllArgumentsAreResolved()
        {
            CallScope callScope = new CallScope(new MockScope());

            ExprOp testExprOp = new ExprOp(OpKindEnum.VALUE) { AsValue = Value.Get(55) };
            callScope.PushFront(Value.Get(testExprOp));

            Value result = callScope.Value();

            Assert.Equal(55, callScope.Args.AsSequence[0].AsLong);
        }
Esempio n. 11
0
        public void Option_Call_CallsHandlerIfArgsNotEmpty()
        {
            Option    option1 = new Option("myname_");
            CallScope scope1  = new CallScope(new EmptyScope());

            scope1.PushFront(Value.Get("str"));
            Value val = option1.Call(scope1);

            Assert.IsTrue(val.AsBoolean);
            Assert.IsTrue(option1.Handled);
            Assert.AreEqual("str", option1.Value);
        }
Esempio n. 12
0
        public void Option_Handler_ChecksThatTheFirstArgumentIsStringWhenWantsArgIsNo()
        {
            Option    option1 = new Option("myname");
            CallScope scope1  = new CallScope(new EmptyScope());

            scope1.PushFront(Value.Get("string"));
            option1.Handler(scope1);
            Assert.IsTrue(option1.Handled); // Indicates that the call was successfull

            Option    option2 = new Option("myname");
            CallScope scope2  = new CallScope(new EmptyScope());

            scope2.PushBack(Value.Get(true));
            option2.Handler(scope2);
        }
Esempio n. 13
0
        public void Option_Handler_ChecksThatTheFirstArgumentIsStringWhenWantsArgIsYes()
        {
            Option    option1 = new Option("myname_");
            CallScope scope1  = new CallScope(new EmptyScope());

            scope1.PushFront(Value.Get("string"));
            scope1.PushBack(Value.Get(true));
            option1.Handler(scope1);
            Assert.Equal("true", option1.Value); // Indicates that the call was successfull

            Option    option2 = new Option("myname_");
            CallScope scope2  = new CallScope(new EmptyScope());

            scope2.PushBack(Value.Get(true));
            scope2.PushBack(Value.Get(true));
            Assert.Throws <InvalidOperationException>(() => option2.Handler(scope2));
        }