Beispiel #1
0
    public void LoadAndShowBestScores()
    {
        var model     = new StubPuzzleDomainModel();
        var view      = new BestScoresForm();
        var presenter = new BestScoresPresenter(model, view);

        // Способ 1
        var thread = new Thread(() => { view.ShowDialog(); })
        {
            IsBackground = true
        };

        thread.Start();
        // Способ 2
        //Task.Run(() => { view.ShowDialog(); });

        for (int i = 0; i < model.BestScores.Count; i++)
        {
            string name  = model.BestScores[i].Name;
            string moves = model.BestScores[i].Moves + " " + Utils.GetMovesWord(model.BestScores[i].Moves);
            string timer = model.BestScores[i].Timer.ToString(@"hh\:mm\:ss");

            var labelNames  = presenter.View.Labels.Find("nameLabel" + (i + 1), false);
            var labelMoves  = presenter.View.Labels.Find("movesLabel" + (i + 1), false);
            var labelTimers = presenter.View.Labels.Find("timerLabel" + (i + 1), false);

            if (name != labelNames[0].Text || moves != labelMoves[0].Text || timer != labelTimers[0].Text)
            {
                Assert.Fail();
            }
        }
        Assert.Pass();
    }
    private void OnBestScores(object sender, EventArgs e)
    {
        var bestScoresPresenter = new BestScoresPresenter(Model, new BestScoresForm());

        ((Form)bestScoresPresenter.View).ShowDialog();
    }