Пример #1
0
		public void RunTest()
		{
			testNumber++;
			bool actualErasable;
			int actualCrossoutsNumber, actualRemainderNumber;
			DateTime begin;
			TimeSpan elapsed;

			PrintTestInfo();
#if DEBUG
			Console.WriteLine(new string(testSequence));
#endif
			PrintMessage("Checking if sequence is erasable and getting crossout number...");
			begin = DateTime.Now;
			try
			{
				actualErasable = CrossoutChecker.Erasable(testSequence, testPatterns, out actualCrossoutsNumber);
			}
			catch (Exception ex)
			{
				PrintImportant(String.Format("Unexpected exception: {0}", ex.Message));
				return;
			}
			elapsed = DateTime.Now - begin;
			PrintMessage(String.Format("Elapsed time: {0}", elapsed));

			PrintMessage("Getting minimum remainder number...");
			begin = DateTime.Now;
			try
			{
				actualRemainderNumber = CrossoutChecker.MinimumRemainder(testSequence, testPatterns);
			}
			catch (Exception ex)
			{
				PrintImportant(String.Format("Unexpected exception: {0}", ex.Message));
				return;
			}
			elapsed = DateTime.Now - begin;
			totalTime += elapsed;
			PrintMessage(String.Format("Elapsed time: {0}", elapsed));

			try
			{
				CompareResult(expectedErasable, actualErasable, "Erasable");
				CompareResult(expectedCrossoutsNumber, actualCrossoutsNumber, "Crossout number");
				CompareResult(expectedRemainderNumber, actualRemainderNumber, "Remainder number");
			}
			catch (Exception ex)
			{
				PrintImportant(ex.Message);
				Console.WriteLine();
				return;
			}
			PrintImportant("Test passed successfully");
			testSuccess++;
			Console.WriteLine();
		}
Пример #2
0
        public TestResult TestCrossoutsNumber(out string message)
        {
            DateTime t1 = DateTime.Now;
            int      b;

            CrossoutChecker_rozw.Erasable(sequence, patterns, out b);
            if (crossoutNumber == null)
            {
                crossoutNumber = b;
            }
            TimeSpan   ts = DateTime.Now - t1;
            bool       res;
            int        w   = -1;
            TestResult ret = TestResult.OK;
            string     msg = "OK";
            Thread     th  = new Thread(() =>
            {
                if (catchExceptions)
                {
                    try
                    {
                        res = CrossoutChecker.Erasable(sequence, patterns, out w);
                    }
                    catch (ThreadAbortException)
                    {
                        return;
                    }
                    catch (Exception)
                    {
                        ret = TestResult.Exception;
                        msg = "Wyjatek!";
                        return;
                    }
                }
                else
                {
                    res = CrossoutChecker.Erasable(sequence, patterns, out w);
                }
                if (w != crossoutNumber)
                {
                    ret = TestResult.BadCrossoutsNumber;
                    msg = "BLAD: jest " + w.ToString() + " a powinno byc " + crossoutNumber.ToString();
                }
            });

            th.Start();
            if (!th.Join((int)(ts.TotalMilliseconds * mercyConstant) + 50))
            {
                ret = TestResult.Timeout;
                msg = "Timeout!";
                th.Abort();
            }
            th.Join();
            message = msg;
            return(ret);
        }
Пример #3
0
        public TestResult TestResults(out string message)
        {
            bool       res = false;
            int        w;
            TestResult ret = TestResult.OK;
            string     msg = "OK";

            res = CrossoutChecker.Erasable(sequence, patterns, out w);
            if (res != result)
            {
                ret = TestResult.BadResult;
                msg = "BLAD: jest " + res.ToString() + " a powinno byc " + result.ToString();
            }
            message = msg;
            return(ret);
        }
Пример #4
0
        public TestResult TestCrossoutsNumber(out string message)
        {
            bool       res;
            int        w   = -1;
            TestResult ret = TestResult.OK;
            string     msg = "OK";

            res = CrossoutChecker.Erasable(sequence, patterns, out w);
            if (w != crossoutNumber)
            {
                ret = TestResult.BadCrossoutsNumber;
                msg = "BLAD: jest " + w.ToString() + " a powinno byc " + crossoutNumber.ToString();
            }
            message = msg;
            return(ret);
        }