Whitney Martinez 6 år sedan
förälder
incheckning
66663a8124
4 ändrade filer med 129 tillägg och 0 borttagningar
  1. Binär
      .DS_Store
  2. 17
    0
      src/main/java/FizzBuzz.java
  3. 107
    0
      src/test/java/FizzBuzzTest.java
  4. 5
    0
      src/test/java/FizzBuzzTestTest.java

Binär
.DS_Store Visa fil


+ 17
- 0
src/main/java/FizzBuzz.java Visa fil

@@ -1,2 +1,19 @@
1
+import static java.lang.System.out;
2
+
1 3
 public class FizzBuzz {
4
+
5
+
6
+        int words(int fiz){
7
+
8
+            if(fiz % 3 == 0){
9
+                out.println("Fizz");
10
+            }else if(fiz % 5 == 0){
11
+                out.print("Buzz");
12
+            }else if (fiz % 3 == 0 && fiz % 5 == 0 ){
13
+
14
+                out.println("FizzBuzz");
15
+            }
16
+                 out.println(fiz);
17
+                 return fiz;
18
+        }
2 19
 }

+ 107
- 0
src/test/java/FizzBuzzTest.java Visa fil

@@ -1,2 +1,109 @@
1
+import org.junit.Assert;
2
+import org.junit.Test;
3
+
1 4
 public class FizzBuzzTest {
5
+
6
+
7
+    @Test
8
+    public void FizzTest(){
9
+        //Given
10
+        FizzBuzz fizz = new FizzBuzz();
11
+
12
+        int fiz = 3;
13
+
14
+        int expected = 3;
15
+
16
+        //When
17
+
18
+        int actual = fizz.words(fiz);
19
+
20
+        //then
21
+
22
+        Assert.assertEquals(expected,actual);
23
+
24
+
25
+
26
+
27
+
28
+    }
29
+    @Test
30
+    public void FizzTest2(){
31
+        //Given
32
+        FizzBuzz fizz = new FizzBuzz();
33
+
34
+        int fiz = 5;
35
+
36
+        int expected = 5;
37
+
38
+        //When
39
+
40
+        int actual = fizz.words(fiz);
41
+
42
+        //then
43
+
44
+        Assert.assertEquals(expected,actual);
45
+
46
+
47
+    }
48
+    @Test
49
+    public void FizzTest3(){
50
+        //Given
51
+        FizzBuzz fizz = new FizzBuzz();
52
+
53
+        int fiz = 15;
54
+
55
+        int expected = 15;
56
+
57
+        //When
58
+
59
+        int actual = fizz.words(fiz);
60
+
61
+        //then
62
+
63
+        Assert.assertEquals(expected,actual);
64
+
65
+
66
+    }
67
+    @Test
68
+    public void FizzTest4(){
69
+        //Given
70
+        FizzBuzz fizz = new FizzBuzz();
71
+
72
+        int fiz = 2;
73
+
74
+        int expected = 2;
75
+
76
+        //When
77
+
78
+        int actual = fizz.words(fiz);
79
+
80
+        //then
81
+
82
+        Assert.assertEquals(expected,actual);
83
+
84
+
85
+    }
86
+
87
+    @Test
88
+    public void FizzTest5(){
89
+        //Given
90
+        FizzBuzz fizz = new FizzBuzz();
91
+
92
+        int fiz = -2;
93
+
94
+        int expected = -2;
95
+
96
+        //When
97
+
98
+        int actual = fizz.words(fiz);
99
+
100
+        //then
101
+
102
+        Assert.assertEquals(expected,actual);
103
+
104
+
105
+
106
+
107
+
108
+    }
2 109
 }

+ 5
- 0
src/test/java/FizzBuzzTestTest.java Visa fil

@@ -0,0 +1,5 @@
1
+import static org.junit.Assert.*;
2
+
3
+public class FizzBuzzTestTest {
4
+
5
+}