public TestViewModel(ITrainingService training, IPredictionService prediction, IAppStateService state)
        {
            _training   = training;
            _prediction = prediction;
            _state      = state;

            Iterations.Sort(i => i.TrainedAt.Value, SortDirection.Descending);
            _state.KeysChanged += (s, e) =>
            {
                prediction.Initialize(_state.CurrentKeys.PredicationKey);
            };

            _state.PackageChanged += async(s, e) =>
            {
                await GetIterationsAsync();

                IsLocalModelAvailable = (_state.CurrentPackage == null) ? false : _state.CurrentPackage.IsLocalModelAvailable;

                RaisePropertyChanged(nameof(IsReadyToTest));

                if (_state.CurrentPackage == null || !IsReadyToTest)
                {
                    VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                        NewState = "NoPackage"
                    });
                }
                else
                {
                    VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                        NewState = "HasPackage"
                    });
                }
            };



            this.UploadCorrection = new RelayCommand(() =>
            {
            },
                                                     () =>
            {
                if (EvaluationResult == null || _state.CurrentTag == null)
                {
                    return(false);
                }

                return(_state.CurrentTag.Name != EvaluationResult);
            });

            this.DownloadModel = new RelayCommand(async() => {
                var downloadUri = await _training.GetModuleDownloadUriAsync(SelectedIteration.Id);
                if (downloadUri != null)
                {
                    var manager = new PackageManager();
                    manager.ModelDownloadStarted += (s, e) => {
                        VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                            NewState = "DownloadStarted"
                        });
                    };
                    manager.ModelDownloadCompleted += (s, e) => {
                        VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                            NewState = "DownloadCompleted"
                        });
                    };
                    manager.ModelDownloadError += (s, e) => {
                        VisualStateChanged?.Invoke(this, new VisualStateEventArgs {
                            NewState = "DownloadError"
                        });
                    };
                    manager.ModelDownloadProgress += (s, e) => {
                        DownloadProgress = e.Percentage;
                    };
                    var model = await manager.DownloadModelAsync(downloadUri);
                    await _state.CurrentPackage.SaveModelAsync(model);
                    IsLocalModelAvailable = _state.CurrentPackage.IsLocalModelAvailable;
                }
            }, () => { return(SelectedIteration != null); });

            this.RefreshIterations = new RelayCommand(async() => {
                await GetIterationsAsync();
            });
        }