Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new scope and sets it as the current scope, using the specified
        /// container as the container for the new scope.
        /// </summary>
        /// <param name="container">The container to use for the new scope.</param>
        /// <returns>The created scope.</returns>
        public static IFakeScope Create(IFakeObjectContainer container)
        {
            var result = new ChildScope(Current, container);

            Current = result;
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new scope and sets it as the current scope.
        /// </summary>
        /// <returns>The created scope.</returns>
        public static FakeScope Create()
        {
            var result = new ChildScope(FakeScope.Current);

            FakeScope.Current = result;
            return(result);
        }
Ejemplo n.º 3
0
        void ExitChildScope(ChildScope scope)
        {
            if (scope != scopeStack.Peek())
            {
                throw new InvalidOperationException("Invalid expectation scope dispose order");
            }

            scopeStack.Pop();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// removes the binding to the type if any.
 /// </summary>
 /// <param name="type">The type to remove from the scope</param>
 public override void InvalidateBinding(System.Type type)
 {
     if (HttpContext.Current.IsInstance() && ChildScope.IsNull())
     {
         HttpContext.Current.Session[type.FullName] = null;
     }
     else
     {
         base.InvalidateBinding(type);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Removes the definition of a local variable from this command block
        /// </summary>
        /// <param name="localVar"></param>
        /// <returns></returns>
        public bool UndefineLocalVariable(SymbolLocalVariable localVar)
        {
            var declareCommand =
                DeclareVariableCommands.FirstOrDefault(
                    command => command.DataStore.ObjectName == localVar.ObjectName
                    );

            if (ReferenceEquals(declareCommand, null) == false)
            {
                RemoveCommand(declareCommand);
            }

            return(ChildScope.RemoveLocalVariable(localVar));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new scope and sets it as the current scope, using the specified
 /// container as the container for the new scope.
 /// </summary>
 /// <param name="container">The container to usee for the new scope.</param>
 /// <returns>The created scope.</returns>
 public static IFakeScope Create(IFakeObjectContainer container)
 {
     var result = new ChildScope(Current, container);
     Current = result;
     return result;
 }
Ejemplo n.º 7
0
 public void Initialize(IScope parent)
 {
     ParentScope = parent ?? throw new ArgumentNullException(nameof(parent));
     ChildScope?.Initialize(this);
 }
Ejemplo n.º 8
0
 IDisposable BeginChildScope(ChildScope childScope)
 {
     RootScope.Add(childScope, false);
     scopeStack.Push(childScope);
     return(childScope);
 }