public ProcessTokenCacheStorageTests() { _testAppContext1 = new AuthContext { ClientId = "test_app_id_1" }; GraphSessionInitializer.InitializeSession(); }
public ProcessTokenCacheStorageTests(ITestOutputHelper outputHelper) { _testAppContext1 = new AuthContext { ClientId = "test_app_id_1" }; GraphSessionInitializer.InitializeSession(); GraphSessionInitializer.InitializeOutput(new PsGraphOutputWriter { WriteError = (exception, s, arg3, arg4) => { outputHelper.WriteLine(exception.Message); }, WriteDebug = outputHelper.WriteLine, WriteInformation = (o, strings) => outputHelper.WriteLine(o.ToString()), WriteObject = outputHelper.WriteLine, WriteVerbose = outputHelper.WriteLine }); }
public void ShouldInitializeOutputWriter() { GraphSessionInitializer.InitializeSession(); GraphSessionInitializer.InitializeOutput(new PsGraphOutputWriter { WriteError = (exception1, s, arg3, arg4) => _helper.WriteLine(exception1.Message), WriteObject = _helper.WriteLine, WriteDebug = _helper.WriteLine, WriteInformation = (o, s) => _helper.WriteLine(s), WriteVerbose = _helper.WriteLine }); GraphSession.Instance.OutputWriter.WriteObject("Output"); Assert.NotNull(GraphSession.Instance.OutputWriter); Assert.NotNull(GraphSession.Instance.OutputWriter.WriteObject); // reset static instance. GraphSession.Reset(); }
protected override void ProcessRecord() { base.ProcessRecord(); try { using (var asyncCommandRuntime = new CustomAsyncCommandRuntime(this, _cancellationTokenSource.Token)) { // Init output to this Cmdlet GraphSessionInitializer.InitializeOutput(asyncCommandRuntime); asyncCommandRuntime.Wait(ProcessRecordAsync(), _cancellationTokenSource.Token); } } catch (AggregateException aggregateException) { // unroll the inner exceptions to get the root cause foreach (var innerException in aggregateException.Flatten().InnerExceptions) { var errorRecords = innerException.Data; if (errorRecords.Count > 1) { foreach (DictionaryEntry dictionaryEntry in errorRecords) { WriteError((ErrorRecord)dictionaryEntry.Value); } } else { WriteError(new ErrorRecord(innerException, string.Empty, ErrorCategory.NotSpecified, null)); } } } catch (Exception exception) when(exception as PipelineStoppedException == null || (exception as PipelineStoppedException).InnerException != null) { // Write exception out to error channel. WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.NotSpecified, null)); } }
/// <summary> /// Globally initializes GraphSession. /// </summary> public void OnImport() { GraphSessionInitializer.InitializeSession(); GraphSession.Instance.DataStore = new DiskDataStore(); }
/// <summary> /// Globally initializes GraphSession. /// </summary> public void OnImport() { GraphSessionInitializer.InitializeSession(); }