public void WhenScopeIsNull_ThrowsArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         ScopeExtensions.AllowsSubject(null, "subject");
     });
 }
 public void WhenSubjectIsNullOrEmpty_ThrowsArgumentNull(string subject)
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         ScopeExtensions.AllowsSubject(new Scope(), subject);
     });
 }
 public void WhenScopeIsNull_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         ScopeExtensions.HasOwnerScope(null);
     });
 }
 public void WhenScopeIsNull_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         ScopeExtensions.AllowsActions(null, NuGetScopes.PackagePush);
     });
 }
예제 #5
0
 /// <summary>
 /// Lookups for a variable definition. If variable exists returns TRUE and the variable, otherwise FALSE.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="variable"></param>
 /// <returns></returns>
 public bool TryGetVariable(string name, out IVariableDeclaration variable)
 {
     name = ScopeExtensions.NormalizeVariableName(name);
     return(thisMembers.TryGetValue(name, out variable) ||
            variables.TryGetValue(name, out variable) ||
            (Parent != null && Parent.TryGetVariable(name, out variable)));
 }
예제 #6
0
        public void ScopeExtensions_SearchScope_ReturnsCurrentScopeIfSearchTypeMatches()
        {
            MockScope scope  = new MockScope();
            MockScope result = ScopeExtensions.SearchScope <MockScope>(scope);

            Assert.Equal(scope, result);
        }
예제 #7
0
        public void ScopeExtensions_SearchScope_ReturnsNullIfNoSuccess()
        {
            MockScope scope  = new MockScope();
            Scope     result = ScopeExtensions.SearchScope <TestChildScope>(scope);

            Assert.Null(result);
        }
예제 #8
0
        public void ScopeExtensions_SearchScope_MakesReqursiveCallForChildScope()
        {
            MockScope  parent     = new MockScope();
            ChildScope childScope = new TestChildScope(parent);

            MockScope result = ScopeExtensions.SearchScope <MockScope>(childScope);

            Assert.Equal(parent, result);
        }
예제 #9
0
        public void ScopeExtensions_SearchScope_MakesReqursiveCallForBindScope()
        {
            MockScope parent     = new MockScope();
            MockScope grandChild = new MockScope();
            BindScope bindScope  = new BindScope(parent, grandChild);

            MockScope result = ScopeExtensions.SearchScope <MockScope>(bindScope);

            Assert.Equal(grandChild, result);
        }
 public void TestResolveAll()
 {
     Assert.DoesNotThrow(() =>
     {
         Assert.DoesNotThrow(() =>
         {
             ScopeExtensions.TestAutofacDependency(new IModule[]
             {
                 new ServiceModule("---")
             });
         });
     });
 }
예제 #11
0
        /// <summary>
        /// Defines a variable with name and type.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public IVariableDeclaration DefineVariable(string name, Type value)
        {
            var normalizedName = ScopeExtensions.NormalizeVariableName(name);
            var variable       = variables[normalizedName] = new VariableDeclaration(name, value);

            if (normalizedName == ScopeExtensions.NormalizeVariableName(ScopeExtensions.ThisName))
            {
                thisMembers.Clear();
                var cqlType = TypeSystem.GetTypeByNative(GetValueType(variable.Value));
                foreach (var property in cqlType.Members)
                {
                    thisMembers.Add(ScopeExtensions.NormalizeVariableName(property.Name), new VariableDeclaration(property.Name, GetPropertyValue(value, property)));
                }
            }
            return(variable);
        }
예제 #12
0
파일: Item.cs 프로젝트: wittyansh/nledger
        private static Value GetTag(CallScope args)
        {
            Item  item = ScopeExtensions.FindScope <Item>(args);
            Value val  = null;

            if (args.Size == 1)
            {
                if (args[0].Type == ValueTypeEnum.String)
                {
                    val = item.GetTag(args.Get <string>(0));
                }
                else if (args[0].Type == ValueTypeEnum.Mask)
                {
                    val = item.GetTag(args.Get <Mask>(0));
                }
                else
                {
                    throw new RuntimeError(String.Format(RuntimeError.ErrorMessageExpectedStringOrMaskForArgument1ButReceivedSmth, args[0].ToString()));
                }
            }
            else if (args.Size == 2)
            {
                if (args[0].Type == ValueTypeEnum.Mask && args[1].Type == ValueTypeEnum.Mask)
                {
                    val = item.GetTag(args.Get <Mask>(0), args.Get <Mask>(1));
                }
                else
                {
                    throw new RuntimeError(String.Format(RuntimeError.ErrorMessageExpectedMasksForArguments1and2ButReceivedSmthAndSmth, args[0].ToString(), args[1].ToString()));
                }
            }
            else if (args.Size == 0)
            {
                throw new RuntimeError(RuntimeError.ErrorMessageTooFewArgumentsToFunction);
            }
            else
            {
                throw new RuntimeError(RuntimeError.ErrorMessageTooManyArgumentsToFunction);
            }

            return(Value.IsNullOrEmptyOrFalse(val) ? Value.Empty : val);
        }
예제 #13
0
파일: Xact.cs 프로젝트: taiab/nledger
 private static Value GetWrapper(CallScope scope, Func <Xact, Value> func)
 {
     return(func(ScopeExtensions.FindScope <Xact>(scope)));
 }
예제 #14
0
 public void ScopeExtensions_SearchScope_RequiresScopeObject()
 {
     Assert.Throws <ArgumentNullException>(() => ScopeExtensions.SearchScope <Scope>(null));
 }
예제 #15
0
 public void ScopeExtensions_SearchScope_RequiresScopeObject()
 {
     ScopeExtensions.SearchScope <Scope>(null);
 }