public void PalendromeBisect_InputA_True()
        {
            // Arrange
            var testTester = new TestTester();
            // Act
            var result = testTester.Palendrome_Bisect("A");

            // Assert
            Assert.IsTrue(result);
        }
        public void Palendrome_InputBoob_True()
        {
            // Arrange
            var testTester = new TestTester();
            // Act
            var result = testTester.Palendrome("Boob");

            // Assert
            Assert.IsTrue(result);
        }
        public void PalendromeBisect_InputApple_False()
        {
            // Arrange
            var testTester = new TestTester();
            // Act
            var result = testTester.Palendrome_Bisect("Apple");

            // Assert
            Assert.IsFalse(result);
        }
        public void Add_OnePlusOne_ReturnsTwo()
        {
            // Arrange
            var testTester = new TestTester();

            // Act
            var result = testTester.Add(1, 1);

            // Assert
            Assert.AreEqual(2, result);
        }
Exemplo n.º 5
0
        internal static void StartTest(string name,
                                       IEnumerable <Question> questions,
                                       bool shuffle,
                                       Action onFinish = null,
                                       Action <TestResults> onResults = null,
                                       bool oneOff = false)
        {
            var tester = new TestTester(name, questions, Properties.Settings.Default.testSkippable);

            void testFinish()
            {
                if (tester.DialogResult != DialogResult.OK)
                {
                    onFinish?.Invoke();
                    return;
                }

                var results = tester.Results;

                onResults?.Invoke(results);

                var resultForm = new ResultsForm(name, results, oneOff);

                resultForm.FormClosing += (s, e) =>
                {
                    var result = resultForm.DialogResult;

                    switch (result)
                    {
                    default:
                        // The user has exited the test.
                        onFinish?.Invoke();
                        return;

                    case DialogResult.Abort:
                        // The user is testing incorrect answers.
                        var incorrect = results.Incorrect.Select(x => x.question);

                        if (shuffle)
                        {
                            incorrect.Shuffle();
                        }

                        tester = new TestTester(name, incorrect, Properties.Settings.Default.testSkippable)
                        {
                            onFinish = testFinish
                        };
                        break;

                    case DialogResult.OK:
                        // Try again
                        // Reshuffle questions

                        if (shuffle)
                        {
                            questions.Shuffle();
                        }
                        tester = new TestTester(name, questions, Properties.Settings.Default.testSkippable)
                        {
                            onFinish = testFinish
                        };
                        break;
                    }

                    tester.Show();
                };

                resultForm.Show();
            }

            tester.onFinish = testFinish;

            tester.Show();
        }