Esempio n. 1
0
 private static void TracePeek(EventTraceActivity activity, TrackingContext trackingContext)
 {
     if (activity != null && activity != EventTraceActivity.Empty && trackingContext != null)
     {
         MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.MessageReceiveTransfer(activity, trackingContext.Activity));
     }
 }
Esempio n. 2
0
        public static Metadata ProcessHeaders(Metadata headers)
        {
            if (headers == null)
            {
                throw new ArgumentNullException(nameof(headers));
            }

            Metadata.Entry trackingEntry = headers.FirstOrDefault(x => string.CompareOrdinal(x.Key, s_TrackingContextKeyName) == 0);

            // Retrieve the tracking context from the message header, if it exists.
            if (trackingEntry != null)
            {
                // If an tracking context exists in the message header, always use it to replace the ambient context.
                TrackingContext tc = TrackingContext.DeSerialize(trackingEntry.ValueBytes);
                tc.SetAsCurrent();
            }
            else
            {
                // If no tracking context exists then create one.
                TrackingContext.NewCurrentIfEmpty();

                Debug.Assert(TrackingContext.Current != null);

                // Copy the tracking context to the message header.
                byte[] byteArray = TrackingContext.Serialize(TrackingContext.Current);
                headers.Add(s_TrackingContextKeyName, byteArray);
            }

            return(headers);
        }
Esempio n. 3
0
 public SetStateAsyncResult(SbmpMessageSession sbmpMessageSession, TrackingContext trackingContext, Stream stream, TimeSpan timeout, AsyncCallback callback, object state) : base(sbmpMessageSession.messagingFactory, ((SbmpMessageReceiver)sbmpMessageSession.InnerMessageReceiver).MessageCreator, ((SbmpMessageReceiver)sbmpMessageSession.InnerMessageReceiver).ControlMessageCreator, timeout, callback, state)
 {
     this.sbmpMessageSession = sbmpMessageSession;
     this.trackingContext    = trackingContext;
     this.stream             = stream;
     base.Start();
 }
Esempio n. 4
0
 private static string CreateAndSerializeNewTrackingContext()
 {
     TrackingContext.NewCurrentIfEmpty();
     Debug.Assert(TrackingContext.Current != null);
     byte[] byteArray = TrackingContext.Serialize(TrackingContext.Current);
     return(byteArray.ByteArrayToBase64String());
 }
Esempio n. 5
0
        public async Task AsyncTrackingInterceptor_GivenTrackingContext_WhenReturnAsync_ThenSameTrackingContextReturned()
        {
            var instance    = new TestTrackingService();
            var interceptor = new AsyncTrackingInterceptor();

            ITestTrackingService proxy = s_ProxyGenerator.CreateInterfaceProxyWithTargetInterface <ITestTrackingService>(instance, interceptor.ToInterceptor());

            TrackingContext.NewCurrent();
            TrackingContext currentTrackingContext = TrackingContext.Current;

            currentTrackingContext.Should().NotBeNull();

            TrackingContext returnedTrackingContext = null;
            await proxy.ReturnAsync(() =>
            {
                returnedTrackingContext = TrackingContext.Current;
            }).ConfigureAwait(false);

            TrackingContext.Current.Should().NotBeNull();
            TrackingContext.Current.CallChainId.Should().Be(currentTrackingContext.CallChainId);
            TrackingContext.Current.OriginatorUtcTimestamp.Should().Be(currentTrackingContext.OriginatorUtcTimestamp);

            returnedTrackingContext.Should().NotBeNull();
            returnedTrackingContext.CallChainId.Should().Be(currentTrackingContext.CallChainId);
            returnedTrackingContext.OriginatorUtcTimestamp.Should().Be(currentTrackingContext.OriginatorUtcTimestamp);
        }
        /// <summary>
        /// Method intended to be called when starting a processing step in the middle of an orchestration. It is expected
        /// that a tracking context has been created previously, at the start of the orchestration by a call to <see
        /// cref="Process.Initiate(XLANGMessage)"/> or by a call to this method. A new processing step tracking activity
        /// is always started, and it is always linked to the process tracking activity identified in <paramref
        /// name="trackingContext"/>.
        /// </summary>
        /// <param name="trackingContext">
        ///   The tracking context that is applicable just before entering the new processing step.
        /// </param>
        /// <param name="processingStepName">
        ///   The name of the processing step entered.
        /// </param>
        /// <returns>
        /// The new <see cref="TrackingContext"/> for the processing step scope.
        /// </returns>
        public static TrackingContext Initiate(TrackingContext trackingContext, string processingStepName)
        {
            if (string.IsNullOrEmpty(processingStepName))
            {
                throw new ArgumentException("Processing step name is null or empty.", "processingStepName");
            }
            if (trackingContext.ProcessActivityId.IsNullOrEmpty())
            {
                throw new ArgumentException("trackingContext.ProcessActivityId is null or empty: process tracking has not been initiated.", "trackingContext");
            }

            var processingStep = new ProcessingStep();

            processingStep.BeginProcessingStepActivity();
            processingStep.BeginTime         = DateTime.UtcNow;
            processingStep.MachineName       = Environment.MachineName;
            processingStep.ProcessActivityID = trackingContext.ProcessActivityId;
            processingStep.Status            = TrackingStatus.Pending;
            processingStep.StepName          = processingStepName;
            // set up continuation for later processing step completion or failure
            processingStep.EnableContinuation();
            processingStep.CommitProcessingStepActivity();
            processingStep.EndProcessingStepActivity();

            // propagate the tracking context with this processing step's activity id
            var newTrackingContext = trackingContext;

            newTrackingContext.ProcessingStepActivityId = processingStep.ActivityId;
            return(newTrackingContext);
        }
        public void TrackingContextIsRestoredForSolicitResponseInboundMessageUnlessNegativeCacheDuration()
        {
            var transmitWorkId = Guid.NewGuid().ToString();

            var trackingContext = new TrackingContext {
                ProcessActivityId        = ActivityId.NewActivityId(),
                ProcessingStepActivityId = ActivityId.NewActivityId(),
                MessagingStepActivityId  = ActivityId.NewActivityId()
            };

            MessageMock.Setup(m => m.GetProperty(BtsProperties.IsSolicitResponse)).Returns(true);
            MessageMock.Setup(m => m.GetProperty(BtsProperties.InboundTransportLocation)).Returns("inbound-transport-location");
            MessageMock.Setup(m => m.GetProperty(BtsProperties.TransmitWorkId)).Returns(transmitWorkId);

            var sut = CreateActivityTracker();

            sut.TrackingContextCacheDuration = TimeSpan.FromSeconds(-1);

            sut.Execute(PipelineContextMock.Object, MessageMock.Object);

            CacheMock.VerifyAll();

            // verifies that TrackingContext fields have been restored in message.Context
            MessageMock.Verify(m => m.SetProperty(TrackingProperties.ProcessActivityId, trackingContext.ProcessActivityId), Times.Never());
            MessageMock.Verify(m => m.SetProperty(TrackingProperties.ProcessingStepActivityId, trackingContext.ProcessingStepActivityId), Times.Never());
            MessageMock.Verify(m => m.SetProperty(TrackingProperties.MessagingStepActivityId, trackingContext.MessagingStepActivityId), Times.Never());
        }
Esempio n. 8
0
        //This is not controlled by smh.cT because its scope is the entire segment over which the challenge executes,
        //not just the boss phase. In the case of BPoHC stage events, this scope is the phase cT of the stage section.
        private IEnumerator TrackChallenges(IChallengeRequest cr, Action <InstanceRecord> onSuccess)
        {
            while (Exec == null)
            {
                yield return(null);
            }
            var challenges = cr.Challenges;
            var ctx        = new TrackingContext(Exec, this, onSuccess);

            for (; completion == null; ctx.t += ETime.FRAME_TIME)
            {
                for (int ii = 0; ii < challenges.Length; ++ii)
                {
                    if (!challenges[ii].FrameCheck(ctx))
                    {
                        ChallengeFailed(cr, ctx);
                        yield break;
                    }
                }
                yield return(null);
            }
            for (int ii = 0; ii < challenges.Length; ++ii)
            {
                if (!challenges[ii].EndCheck(ctx, completion.Value))
                {
                    ChallengeFailed(cr, ctx);
                    yield break;
                }
            }
            ChallengeSuccess(cr, ctx);
        }
Esempio n. 9
0
 private static void TraceRenewLock(EventTraceActivity fromActivity, TrackingContext trackingContext)
 {
     if (trackingContext != null && fromActivity != null && fromActivity != EventTraceActivity.Empty)
     {
         MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.RenewSessionLockTransfer(fromActivity, trackingContext.Activity));
     }
 }
 public RenewLockLoopAsyncResult(MessageReceivePump pump, TrackingContext trackingContext, BrokeredMessage message, CancellationToken cancellationToken, AsyncCallback callback, object state) : base(TimeSpan.MaxValue, callback, state)
 {
     this.pump              = pump;
     this.trackingContext   = trackingContext;
     this.message           = message;
     this.cancellationToken = cancellationToken;
 }
Esempio n. 11
0
 private void ChallengeSuccess(IChallengeRequest cr, TrackingContext ctx)
 {
     if (cr.OnSuccess(ctx))
     {
         CleanupState();
     }
 }
        private static void OnCompleteMessageCompletion(IAsyncResult result)
        {
            MessageReceivePump.BatchCompleteAsyncResult batchCompleteAsyncResult = (MessageReceivePump.BatchCompleteAsyncResult)result;
            MessageReceivePump pump            = batchCompleteAsyncResult.Pump;
            TrackingContext    trackingContext = batchCompleteAsyncResult.TrackingContext;

            lock (pump.completionList)
            {
                try
                {
                    try
                    {
                        AsyncResult <MessageReceivePump.BatchCompleteAsyncResult> .End(batchCompleteAsyncResult);
                    }
                    catch (Exception exception1)
                    {
                        Exception exception = exception1;
                        MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.MessageReceivePumpFailedToComplete(trackingContext.Activity, trackingContext.TrackingId, trackingContext.SystemTracker, exception.ToStringSlim()));
                        pump.RaiseExceptionReceivedEvent(exception, "Complete");
                    }
                }
                finally
                {
                    pump.completionInProgress = false;
                }
            }
            pump.ScheduleMessageCompletion(null, trackingContext);
        }
Esempio n. 13
0
        public async Task TrackingContext_MultipleParallelTasks_NewContextAlwaysCreated()
        {
            var results    = new ConcurrentStack <bool>();
            var nullChecks = new ConcurrentStack <bool>();

            var runningTasks = new List <Task>();

            for (int i = 0; i < 10; i++)
            {
                runningTasks.Add(Task.Run(() =>
                {
                    TrackingContext.ClearCurrent();
                    Assert.IsNull(TrackingContext.Current);

                    ParallelTester.Test(i, results, nullChecks);
                }));
            }

            await Task.WhenAll(runningTasks.ToArray());

            foreach (bool result in results)
            {
                Assert.IsFalse(result);
            }

            foreach (bool nullCheck in nullChecks)
            {
                Assert.IsFalse(nullCheck);
            }
        }
Esempio n. 14
0
 public RetryBrowserAsyncResult(MessageBrowser browser, TrackingContext trackingContext, int messageCount, long fromSequenceNumber, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state)
 {
     this.browser            = browser;
     this.messageCount       = messageCount;
     this.fromSequenceNumber = fromSequenceNumber;
     this.trackingContext    = trackingContext;
 }
Esempio n. 15
0
        static async Task Test_QueryMembershipSequential(ILogger serilog)
        {
            try
            {
                Console.WriteLine("\r\nSequential...");

                var proxy = GetProxy(serilog);
                for (int i = 0; i < 10; i++)
                {
                    // This renews the call chain ID.
                    TrackingContext.NewCurrent();

                    Debug.Assert(TrackingContext.Current != null);

                    string response = await proxy.RegisterMemberAsync(GetRegisterRequest(TrackingContext.Current.CallChainId.ToString())).ConfigureAwait(false);

                    Console.WriteLine(response);
                }

                Console.WriteLine("\r\nFinished...");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Test Exception: " + ex.Message);
            }
        }
Esempio n. 16
0
 private static void TraceSetState(EventTraceActivity fromActivity, TrackingContext trackingContext, string sessionId)
 {
     if (trackingContext != null && fromActivity != null && fromActivity != EventTraceActivity.Empty)
     {
         MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.SetStateTransfer(fromActivity, trackingContext.Activity, sessionId));
     }
 }
        public async Task <bool> IsTrackedAsync(string url, int userId)
        {
            using var _trackingContext = new TrackingContext(_options);
            var items = _trackingContext.Items.Where(i => i.Url.Equals(url) && i.UserId == userId);

            return(await items.AnyAsync());
        }
Esempio n. 18
0
        public string CreateRelease(string releaseName)
        {
            try
            {
                command = new SqlCommand("CreateRelease", TrackingContext.GetConnection())
                {
                    CommandType = CommandType.StoredProcedure
                };

                command.Parameters.AddRange(new SqlParameter[] {
                    new SqlParameter("@ReleaseName", releaseName)
                });

                SqlParameter message = new SqlParameter
                {
                    ParameterName = "@Message",
                    SqlDbType     = SqlDbType.VarChar,
                    Direction     = ParameterDirection.Output,
                    Size          = 50
                };

                command.Parameters.Add(message);

                command.ExecuteNonQuery();

                return(message.Value.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void TrackingContextIsCachedForSolicitResponseOutboundMessage()
        {
            var transmitWorkId = Guid.NewGuid().ToString();

            var trackingContext = new TrackingContext {
                ProcessActivityId        = ActivityId.NewActivityId(),
                ProcessingStepActivityId = ActivityId.NewActivityId(),
                MessagingStepActivityId  = ActivityId.NewActivityId()
            };

            MessageMock.Setup(m => m.GetProperty(BtsProperties.IsSolicitResponse)).Returns(true);
            MessageMock.Setup(m => m.GetProperty(BtsProperties.OutboundTransportLocation)).Returns("outbound-transport-location");
            MessageMock.Setup(m => m.GetProperty(BtsProperties.TransmitWorkId)).Returns(transmitWorkId);
            MessageMock.Setup(m => m.GetProperty(TrackingProperties.ProcessActivityId)).Returns(trackingContext.ProcessActivityId);
            MessageMock.Setup(m => m.GetProperty(TrackingProperties.ProcessingStepActivityId)).Returns(trackingContext.ProcessingStepActivityId);
            MessageMock.Setup(m => m.GetProperty(TrackingProperties.MessagingStepActivityId)).Returns(trackingContext.MessagingStepActivityId);

            CacheMock.Setup(c => c.Set(transmitWorkId, trackingContext, 60 + 1));

            var sut = CreateActivityTracker();

            sut.Execute(PipelineContextMock.Object, MessageMock.Object);

            CacheMock.VerifyAll();
        }
Esempio n. 20
0
        private void InitFSM()
        {
            messages = new ObservableCollection <string>();
            lstMessages.DataContext = messages;
            lstMessages.ItemsSource = messages;

            string file = Path.GetDirectoryName(new Uri(Assembly.GetAssembly(typeof(MainWindow)).CodeBase).LocalPath);

            Configuration cfg = Configuration.Instance;

            cfg.GesturesFolder = file + @"\..\..\Gestures\";
            cfg.InitializeFrom(file + @"\..\..\gesturesConfig.xml");

            context = cfg.CreateContext();
            fsm     = new GesturesFSM <TrackingContext>(context);
            fsm.InitializeFromConfiguration(cfg);

            // bind to recording state events
            recordingState = (StateRecording)cfg.States[FSMStateId.Recording];
            recordingState.RecordingStarted  += new GestureRecordingHandler(recordingState_RecordingStarted);
            recordingState.RecordingStarting += new GestureRecordingHandler(recordingState_RecordingStarting);
            recordingState.RecordingStopped  += new GestureRecordingHandler(recordingState_RecordingStopped);
            recordingState.FrameRecorded     += new GestureRecordingHandler(recordingState_FrameRecorded);

            // bind to fsm events
            fsm.GestureRecognized += new GestureRecognizedEventHandler(fsm_GestureRecognized);
            fsm.StateChanged      += new StateChangedEventHandler(fsm_StateChanged);
        }
        public void FindProcessAndCreateMessagingStepBeforeStreamFirstReadEvent()
        {
            var trackingContext = new TrackingContext {
                ProcessActivityId = ActivityId.NewActivityId(),
            };

            using (var stream = new TrackingStream(new StringStream("some-content")))
            {
                MessageMock.Object.BodyPart.Data = stream;
                MessageMock.Setup(m => m.GetProperty(BtsProperties.OutboundTransportLocation)).Returns("outbound-transport-location");
                MessageMock.Setup(m => m.GetProperty(TrackingProperties.ProcessActivityId)).Returns(trackingContext.ProcessActivityId);
                MessageMock.Setup(m => m.GetProperty(TrackingProperties.MessagingStepActivityId)).Returns(trackingContext.MessagingStepActivityId);

                var sut = ActivityTracker.Create(new MicroComponent.ActivityTracker.Context(PipelineContextMock.Object, MessageMock.Object, ActivityTrackingModes.Step));
                sut.TrackActivity();

                ActivityFactory.Verify(
                    af => af.CreateProcess(It.IsAny <IBaseMessage>(), It.IsAny <string>()),
                    Times.Never());
                ActivityFactory.Verify(
                    af => af.FindProcess(It.Is <TrackingContext>(c => c.ProcessActivityId == trackingContext.ProcessActivityId)),
                    Times.Once());
                ActivityFactory.Verify(
                    af => af.CreateMessagingStep(It.IsAny <IBaseMessage>()),
                    Times.Once());
                ActivityFactory.Verify(
                    af => af.FindMessagingStep(It.IsAny <TrackingContext>()),
                    Times.Never());
            }
        }
Esempio n. 22
0
 public static void AddTrackingIdHeader(this HttpWebRequest request, TrackingContext trackingContext)
 {
     if (trackingContext != null)
     {
         request.Headers["TrackingId"] = trackingContext.TrackingId;
     }
 }
Esempio n. 23
0
        public Array GetByCondition(CriteriaModel condition, TrackingContext context)
        {
            switch (condition.FieldName)
            {
            case "ActDepartureDate":
                return(context.Shipment.Where(ship =>
                                              ship.ActDepartureDate >= DateTime.Parse(condition.FieldFromValue) &&
                                              ship.ActDepartureDate <= DateTime.Parse(condition.FieldToValue)
                                              ).OrderBy(ship => ship.BillOfLading).ToArray());

            case "EstArrivalDate":
                return(context.Shipment.Where(ship =>
                                              ship.EstArrivalDate >= DateTime.Parse(condition.FieldFromValue) &&
                                              ship.EstArrivalDate <= DateTime.Parse(condition.FieldToValue)
                                              ).OrderBy(ship => ship.BillOfLading).ToArray());

            case "BillOfLading":
                return(context.Shipment.Where(ship =>
                                              ship.BillOfLading == condition.FieldFromValue)
                       .OrderBy(ship => ship.BillOfLading).ToArray());

            default:
                return(context.Shipment.Where(ship => !ship.IsClosed)
                       .OrderBy(ship => ship.BillOfLading).ToArray());
            }
        }
 public BatchedObjectsAsyncResult(TrackingContext trackingContext, IEnumerable <TItem> batchedObjects, int batchSize, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.TrackingContext = trackingContext;
     this.BatchedObjects  = batchedObjects;
     this.BatchSize       = batchSize;
     this.timeoutHelper   = new Microsoft.ServiceBus.Common.TimeoutHelper(timeout);
 }
        public static (bool, int[]) AddTestData <TEntity>(this TrackingContext context, int quantity) where TEntity : class
        {
            for (int i = 0; i < quantity; i++)
            {
                var entity     = Activator.CreateInstance <TEntity>();
                var properties = entity.GetType().GetProperties();

                foreach (var property in properties)
                {
                    if (property.Name == "Id")
                    {
                        continue;
                    }

                    if (property.PropertyType == typeof(string))
                    {
                        property.SetValue(entity, Random.GenerateString(10));
                    }
                }
                context.Set <TEntity>().Add(entity);
            }

            context.SaveChanges();

            return(true, context.Set <TEntity>().Select(x => (int)x.GetType().GetProperty("Id").GetValue(x)).ToArray());
        }
            public static void StartBatchOperation(BatchManager <TItem> .PerformFlushAsyncResult thisPtr, IList <BatchManager <TItem> .BatchedObjectsAsyncResult> batchedObjectsAsyncResults)
            {
                List <TItem> tItems = new List <TItem>();

                foreach (BatchManager <TItem> .BatchedObjectsAsyncResult batchedObjectsAsyncResult in batchedObjectsAsyncResults)
                {
                    TrackingContext trackingContext = batchedObjectsAsyncResult.TrackingContext;
                    MessagingClientEtwProvider.TraceClient(() => {
                    });
                    tItems.AddRange(batchedObjectsAsyncResult.BatchedObjects);
                }
                try
                {
                    IAsyncResult batchedBegin = thisPtr.BatchManager.BatchedBegin(thisPtr.TrackingContext, tItems, thisPtr.transactionId, thisPtr.timeout, BatchManager <TItem> .PerformFlushAsyncResult.onFlushCompletionCallback, new Tuple <BatchManager <TItem> .PerformFlushAsyncResult, IList <BatchManager <TItem> .BatchedObjectsAsyncResult> >(thisPtr, batchedObjectsAsyncResults));
                    if (batchedBegin.CompletedSynchronously)
                    {
                        thisPtr.OnFlushCompleted(batchedBegin, batchedObjectsAsyncResults);
                    }
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                    thisPtr.TryContinueOperation(true, exception, batchedObjectsAsyncResults);
                }
            }
 public SendAsyncResult(SendAvailabilityPairedNamespaceMessageSender sender, TrackingContext trackingContext, IEnumerable <BrokeredMessage> messages, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state)
 {
     this.sender          = sender;
     this.trackingContext = trackingContext;
     this.messages        = messages;
     this.messageBuffer   = new List <BrokeredMessage>();
     try
     {
         foreach (BrokeredMessage message in this.messages)
         {
             message.IsConsumed = false;
             this.messageBuffer.Add(message.Clone());
         }
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteRetryPolicyStreamNotClonable(this.trackingContext.Activity, this.trackingContext.TrackingId, "PairnedNamespaceSender", "Send", exception.GetType().FullName, exception.Message));
         foreach (BrokeredMessage brokeredMessage in this.messageBuffer)
         {
             brokeredMessage.Dispose();
         }
         this.messageBuffer.Clear();
     }
     base.Start();
 }
Esempio n. 28
0
        static void Test_QueryMembershipConcurrent(ILogger serilog)
        {
            try
            {
                Console.WriteLine("\r\nConcurrent...");

                var proxy = GetProxy(serilog);
                var tasks = new List <Task <string> >();
                for (int i = 0; i < 10; i++)
                {
                    // This renews the call chain ID.
                    TrackingContext.NewCurrent();

                    Debug.Assert(TrackingContext.Current != null);

                    Task <string> response = proxy.RegisterMemberAsync(GetRegisterRequest(TrackingContext.Current.CallChainId.ToString()));
                    tasks.Add(response);
                }
                Task.WaitAll(tasks.ToArray());

                foreach (var item in tasks)
                {
                    Console.WriteLine(item.Result);
                }

                Console.WriteLine("\r\nFinished...");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Test Exception: " + ex.Message);
            }
        }
Esempio n. 29
0
 public ArmyRepository(IBattleRepository battleRepository, TrackingContext trackingContext, NonTrackingContext nonTrackingContext, ILogger <ArmyRepository> logger)
 {
     _battleRepository   = battleRepository;
     _trackingContext    = trackingContext;
     _nonTrackingContext = nonTrackingContext;
     _logger             = logger;
 }
        public async Task TrackingContext_GivenMultipleParallelTasks_ThenNewContextAlwaysCreated()
        {
            var results    = new ConcurrentStack <bool>();
            var nullChecks = new ConcurrentStack <bool>();

            var runningTasks = new List <Task>();

            for (int i = 0; i < 10; i++)
            {
                runningTasks.Add(Task.Run(() =>
                {
                    TrackingContext.ClearCurrent();
                    TrackingContext.Current.Should().BeNull();

                    ParallelTester.Test(i, results, nullChecks);
                }));
            }

            await Task.WhenAll(runningTasks.ToArray());

            foreach (bool result in results)
            {
                result.Should().BeFalse();
            }

            foreach (bool nullCheck in nullChecks)
            {
                nullCheck.Should().BeFalse();
            }
        }