public void TestInitialize(string jsonSchema) { // Initialize contexts, callbacks, and actions. this.sessionId = Guid.NewGuid(); this.forgeState = new ForgeDictionary(new Dictionary <string, object>(), this.sessionId); this.callbacks = new TreeWalkerCallbacks(); this.token = new CancellationTokenSource().Token; this.UserContext.Name = "MyName"; this.UserContext.ResourceType = "Container"; this.UserContext.GetCount = (Func <Int32>)(() => { return(1); }); this.UserContext.GetCountAsync = (Func <Task <Int32> >)(() => { return(Task.FromResult(2)); }); this.parameters = new TreeWalkerParameters( this.sessionId, jsonSchema, this.forgeState, this.callbacks, this.token) { UserContext = this.UserContext, ForgeActionsAssembly = typeof(CollectDiagnosticsAction).Assembly }; this.session = new TreeWalkerSession(this.parameters); }
/// <summary> /// Instantiates a TreeWalkerParameters object with the properies that are required to instantiate a TreeWalkerSession object. /// </summary> /// <param name="sessionId">The unique identifier for this session.</param> /// <param name="jsonSchema">The JSON schema.</param> /// <param name="forgeState">The Forge state.</param> /// <param name="callbacks">The callbacks object.</param> /// <param name="token">The cancellation token.</param> public TreeWalkerParameters( Guid sessionId, string jsonSchema, IForgeDictionary forgeState, ITreeWalkerCallbacks callbacks, CancellationToken token) { if (sessionId == Guid.Empty) { throw new ArgumentNullException("sessionId"); } if (string.IsNullOrWhiteSpace(jsonSchema)) { throw new ArgumentNullException("jsonSchema"); } if (forgeState == null) { throw new ArgumentNullException("forgeState"); } if (callbacks == null) { throw new ArgumentNullException("callbacks"); } if (token == null) { throw new ArgumentNullException("token"); } this.SessionId = sessionId; this.JsonSchema = jsonSchema; this.ForgeState = forgeState; this.Callbacks = callbacks; this.Token = token; }
/// <summary> /// Instantiates a TreeWalkerParameters object with the properties that are required to instantiate a TreeWalkerSession object. /// </summary> /// <param name="sessionId">The unique identifier for this session.</param> /// <param name="forgeTree">The ForgeTree for this session.</param> /// <param name="forgeState">The Forge state.</param> /// <param name="callbacks">The callbacks object.</param> /// <param name="token">The cancellation token.</param> public TreeWalkerParameters( Guid sessionId, ForgeTree forgeTree, IForgeDictionary forgeState, ITreeWalkerCallbacks callbacks, CancellationToken token) { if (sessionId == Guid.Empty) { throw new ArgumentNullException("sessionId"); } if (forgeTree == null) { throw new ArgumentNullException("forgeTree"); } if (forgeState == null) { throw new ArgumentNullException("forgeState"); } if (callbacks == null) { throw new ArgumentNullException("callbacks"); } if (token == null) { throw new ArgumentNullException("token"); } this.SessionId = sessionId; this.ForgeTree = forgeTree; this.ForgeState = forgeState; this.Callbacks = callbacks; this.Token = token; }