public void TestClassicFizzBuzz() { var stopwatch = Stopwatch.StartNew(); try { Console.Write( "Create student " ); var student = new ClassicFizzBuzzTest( 1, 100 ); Console.WriteLine( $"took {stopwatch.Elapsed.TotalMilliseconds} ms." ); Console.WriteLine( "Student taking test..." ); student.TakeTest(); this.Teacher.Grade( ref student ); } finally { stopwatch.Stop(); Console.WriteLine( $"{nameof( ClassicFizzBuzzTest )} took {stopwatch.Elapsed.TotalMilliseconds:N} ms." ); } Console.WriteLine( "Press enter to quit." ); Console.ReadLine(); }
public void Grade([NotNull] ref ClassicFizzBuzzTest test) { if (test == null) { throw new ArgumentNullException(paramName: nameof(test)); } Assert.True(this.RealAnswers.Count >= 100, $"Missing {nameof( this.RealAnswers )}."); Console.Write("Grading "); var stopwatch = Stopwatch.StartNew(); var areSame = this.RealAnswers.SequenceEqual(test.MyAnswers, StringComparer.OrdinalIgnoreCase); stopwatch.Stop(); Console.WriteLine($"took {stopwatch.Elapsed.TotalMilliseconds} ms."); if (!areSame) { var result = $"The {test.NumbersToCount} answers appear to be wrong."; Console.WriteLine(result); var local = test.MyAnswers.ToList(); for (var i = test.StartingNumber; i < test.EndingNumber; i++) { var me = local[i]; var them = this.RealAnswers[i]; if (me != them) { Console.WriteLine($"[{i}] Me={me} Them={them}."); Debugger.Break(); } } Assert.Fail(result); } }