/// <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); }
/// <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); }
void ExitChildScope(ChildScope scope) { if (scope != scopeStack.Peek()) { throw new InvalidOperationException("Invalid expectation scope dispose order"); } scopeStack.Pop(); }
/// <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); } }
/// <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)); }
/// <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; }
public void Initialize(IScope parent) { ParentScope = parent ?? throw new ArgumentNullException(nameof(parent)); ChildScope?.Initialize(this); }
IDisposable BeginChildScope(ChildScope childScope) { RootScope.Add(childScope, false); scopeStack.Push(childScope); return(childScope); }