コード例 #1
0
        private async void Execute(string fileId, Action assertAction)
        {
            _driveHive = await Utils.PrepareDrives(fileId, _logger);

            var syncEngine = new CryptoDriveSyncEngine(_driveHive.RemoteDrive, _driveHive.LocalDrive, SyncMode.Echo, _logger);

            // Act
            syncEngine.Start();
            await syncEngine.StopAsync();

            // Assert
            assertAction?.Invoke();
        }
コード例 #2
0
        private async void Execute(string fileId, Func <Task> actAction, Action assertAction, int syncId)
        {
            Exception ex = null;

            _driveHive = await Utils.PrepareDrives(fileId, _logger);

            var syncEngine = new CryptoDriveSyncEngine(_driveHive.RemoteDrive, _driveHive.LocalDrive, SyncMode.Echo, _logger);

            syncEngine.SyncCompleted += (sender, e) =>
            {
                if (ex == null && e.Exception != null)
                {
                    ex = e.Exception;
                }

                try
                {
                    if (e.SyncId == 0)
                    {
                        actAction?.Invoke().Wait();
                    }

                    else if (e.SyncId == syncId)
                    {
                        syncEngine.Stop();
                    }
                }
                finally
                {
                    if (e.SyncId == syncId)
                    {
                        _manualReset.Set();
                    }
                }
            };

            // Act
            syncEngine.Start();
            _manualReset.Wait(timeout: TimeSpan.FromSeconds(30));

            // Assert
            assertAction?.Invoke();

            if (ex != null)
            {
                throw ex;
            }

            _driveHive.Dispose();
        }