-
Notifications
You must be signed in to change notification settings - Fork 0
/
HtmlOutput.cs
63 lines (51 loc) · 1.77 KB
/
HtmlOutput.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
namespace FizzBuzz2
{
public class HtmlOutput : IFizzBuzzDelegate, IFizzBuzzWriter
{
private int _upperLimit;
private int _maxLoops;
public void Run(int upperLimit, int maxLoops)
{
_upperLimit = upperLimit;
_maxLoops = maxLoops;
Console.WriteLine(@"<!DOCTYPE html>");
Console.WriteLine(@"<html>");
Console.WriteLine(@"<head>");
Console.WriteLine(@" <title>FizzBuzz Fun!</title>");
Console.WriteLine(@"</head>");
Console.WriteLine(@"<body>");
new FizzBuzz().Run(upperLimit, maxLoops, this);
Console.WriteLine(@"</body>");
Console.WriteLine(@"</html>");
}
public void TestStart(string testFunction)
{
Console.WriteLine(@" <h1>{0}</h1>", testFunction);
Console.WriteLine(@" <table>");
}
public void TestItem(int value, string tag)
{
Console.WriteLine(@" <tr><td>{0}</td><td>{1}</td></tr>", value, tag);
}
public void TestFinish()
{
Console.WriteLine(@" </table>");
}
public void ResultsStart()
{
Console.WriteLine(@" <h1>Results:</h1>");
Console.WriteLine(@" <table>");
}
public void ResultsItem(TimeSpan timeSpan, string testFunction)
{
Console.WriteLine(@" <tr><td>{0}</td><td>{1}</td></tr>", timeSpan, testFunction);
}
public void ResultsFinish()
{
Console.WriteLine(@" </table>");
Console.WriteLine(@" <p>Each test performed {0} times with max range of {1}.<p>",
_maxLoops, _upperLimit);
}
}
}