Пример #1
0
        public async Task ValidateActivityIdWithSynchronizationContext()
        {
            Mock <SynchronizationContext> mockSynchronizationContext = new Mock <SynchronizationContext>()
            {
                CallBase = true
            };

            using CosmosClient cosmosClient = MockCosmosUtil.CreateMockCosmosClient();
            CosmosClientContext clientContext = ClientContextCore.Create(
                cosmosClient,
                new MockDocumentClient(),
                new CosmosClientOptions());

            try
            {
                SynchronizationContext.SetSynchronizationContext(mockSynchronizationContext.Object);

                Guid result = await clientContext.OperationHelperAsync <Guid>(
                    nameof(ValidateActivityIdWithSynchronizationContext),
                    new RequestOptions(),
                    (diagnostics) =>
                {
                    return(this.ValidateActivityIdHelper());
                });

                Assert.AreEqual(Guid.Empty, Trace.CorrelationManager.ActivityId, "ActivityScope was not disposed of");
            }
            finally
            {
                SynchronizationContext.SetSynchronizationContext(null);
            }
        }
Пример #2
0
        public async Task ValidateActivityId()
        {
            using CosmosClient cosmosClient = MockCosmosUtil.CreateMockCosmosClient();
            CosmosClientContext clientContext = ClientContextCore.Create(
                cosmosClient,
                new MockDocumentClient(),
                new CosmosClientOptions());

            Guid result = await clientContext.OperationHelperAsync <Guid>(
                nameof(ValidateActivityId),
                new RequestOptions(),
                (trace) => this.ValidateActivityIdHelper());

            Assert.AreEqual(Guid.Empty, System.Diagnostics.Trace.CorrelationManager.ActivityId, "ActivityScope was not disposed of");
        }