Example #1
0
        public void NotInheritedSetAfterAsyncMethodStartsInAnotherAsyncMethod()
        {
            Assert.False(EventSuppressor.EventsSuppressed,
                         "EventSuppressor shouldn't be active in this thread before test.");

            var         taskCompletionSource = new TaskCompletionSource <object>();
            Func <Task> notInheritedAction   = async() =>
            {
                await taskCompletionSource.Task;
                Assert.False(EventSuppressor.EventsSuppressed, "EventSuppressor shouldn't be active in this thread.");
            };

            var checkTask = notInheritedAction();

            Task.Run(async() =>
            {
                using (EventSuppressor.SupressEvents())
                {
                    Assert.True(EventSuppressor.EventsSuppressed, "EventSuppressor inherits value in another thread!");
                    taskCompletionSource.TrySetResult(null);
                    await checkTask;
                }
                Assert.False(EventSuppressor.EventsSuppressed, "EventSuppressor shouldn't be active in this thread after test.");
            }).Wait();

            Assert.False(EventSuppressor.EventsSuppressed, "EventSuppressor shouldn't be active in this thread after test.");
        }
Example #2
0
        public void SuppressInCurrentThread()
        {
            Assert.False(EventSuppressor.EventsSuppressed, "EventSuppressor shouldn't be active in this thread before test.");

            using (EventSuppressor.SupressEvents())
            {
                Assert.True(EventSuppressor.EventsSuppressed, "EventSuppressor should be active in this thread.");
            }

            Assert.False(EventSuppressor.EventsSuppressed, "EventSuppressor shouldn't be active in this thread after test.");
        }
Example #3
0
        public void InheritedSuppressInAnotherThread()
        {
            Assert.False(EventSuppressor.EventsSuppressed,
                         "EventSuppressor shouldn't be active in this thread before test.");

            using (EventSuppressor.SupressEvents())
            {
                Assert.True(EventSuppressor.EventsSuppressed, "EventSuppressor should be active in this thread.");
                Task.Run(() =>
                {
                    Assert.True(EventSuppressor.EventsSuppressed, "EventSuppressor inherits value in another thread!");
                }).Wait();
            }

            Assert.False(EventSuppressor.EventsSuppressed, "EventSuppressor shouldn't be active in this thread after test.");
        }
Example #4
0
        public async Task ImportAsync(Stream inputStream, PlatformExportManifest importOptions, Action <ExportImportProgressInfo> progressCallback, ICancellationToken сancellationToken)
        {
            if (importOptions == null)
            {
                throw new ArgumentNullException(nameof(importOptions));
            }

            var progressInfo = new ExportImportProgressInfo();

            progressInfo.Description = "Starting platform import...";
            progressCallback(progressInfo);

            using (var zipArchive = new ZipArchive(inputStream, ZipArchiveMode.Read, true))
                using (EventSuppressor.SupressEvents())
                {
                    //Import selected platform entries
                    await ImportPlatformEntriesInternalAsync(zipArchive, importOptions, progressCallback, сancellationToken);

                    //Import selected modules
                    await ImportModulesInternalAsync(zipArchive, importOptions, progressCallback, сancellationToken);
                }
        }