Professional Documents
Culture Documents
Pass Task 3.2: Clock: Swinburne University of Technology
Pass Task 3.2: Clock: Swinburne University of Technology
Pass Task 3.2: Clock: Swinburne University of Technology
Submitted By:
viren shah Tutor:
102110529 Matt Noone
2020/09/18 15:04
Produced by Doubtfire
File 1 of 7 Clock Class
1 using System;
2 using System.Collections.Generic;
3 using System.Data;
4 using System.Text;
5
6 namespace Task3_2
7 {
8 public class Clock
9 {
10 private counter _hour;
11 private counter _minute;
12 private counter _second;
13 private string _time;
14
22 }
23
31 }
32
41 }
42
Page 1 of 11
File 1 of 7 Clock Class
54 }
55
Page 2 of 11
File 2 of 7 Counter Class
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace Task3_2
6 {
7 public class counter
8 {
9 private string _name;
10 private int _count;
11
27 set
28 {
29 _name = value;
30 }
31 }
32
Page 3 of 11
File 2 of 7 Counter Class
54 _count = 0;
55
56 }
57
58
59
60 }
61 }
Page 4 of 11
File 3 of 7 Program Class
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading;
6 using System.Threading.Tasks;
7
8 namespace Task3_2
9 {
10 class Program
11 {
12
23 Console.ReadLine();
24 }
25 }
26 }
Page 5 of 11
File 4 of 7 Clock Unit Tests
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6 using NUnit.Framework;
7 using Task3_2;
8
9 namespace n_Unit
10 {
11 [TestFixture]
12 public class Clock_test
13 {
14 private Clock _test_clock;
15
16 [SetUp]
17
23
24 [TestCase("00:00:00")]
25
31
32
33 [TestCase("00:00:20")]
34 public void Test_ticks_sec(string to_test_true)
35 {
36 for (int i = 0; i < 20; i++)
37 {
38 _test_clock.tick();
39 }
40 Assert.IsTrue(_test_clock.DisplayTime() == to_test_true);
41 }
42
43
44 [TestCase("00:01:00")]
45 public void Test_ticks_min(string to_test_true)
46 {
47 for (int i = 0; i < 60; i++)
48 {
49 _test_clock.tick();
50 }
51 Assert.IsTrue(_test_clock.DisplayTime() == to_test_true);
52 }
53
Page 6 of 11
File 4 of 7 Clock Unit Tests
54
55 [TestCase("01:00:00")]
56 public void Test_ticks_hrs(string to_test_true)
57 {
58 for (int i = 0; i < 3600; i++)
59 {
60 _test_clock.tick();
61 }
62 Assert.IsTrue(_test_clock.DisplayTime() == to_test_true);
63 }
64
65
66 [TestCase("00:00:00")]
67 public void Test_roll_over(string to_test_true)
68 {
69 for (int i = 0; i < 60*60*24; i++)
70 {
71 _test_clock.tick();
72 }
73 Assert.IsTrue(_test_clock.DisplayTime() == to_test_true);
74 }
75
76 [TestCase("00:00:00")]
77 public void Test_reset(string to_test_true)
78 {
79 for (int i = 0; i < 60 * 60 * 25; i++)
80 {
81 _test_clock.tick();
82 }
83 _test_clock.reset();
84 Assert.IsTrue(_test_clock.DisplayTime() == to_test_true);
85 }
86
87
88 }
89 }
Page 7 of 11
File 5 of 7 Screenshot
Page 8 of 11
File 5 of 7 Screenshot
Page 9 of 11
File 6 of 7 Screenshot Unit Tests
Page 10 of 11
File 7 of 7 Image of UML diagram
Page 11 of 11