Преглед на файлове

passed all of Jevit's EZ test

William Brown преди 6 години
родител
ревизия
384b30826a
променени са 2 файла, в които са добавени 26 реда и са изтрити 121 реда
  1. 10
    2
      src/main/java/FizzBuzz.java
  2. 16
    119
      src/test/java/FizzBuzzTest.java

+ 10
- 2
src/main/java/FizzBuzz.java Целия файл

@@ -1,5 +1,13 @@
1 1
 public class FizzBuzz {
2
-    public static String of(int number1) {
3
-        return "";
2
+    public static String count(int number1) {
3
+        if(number1 % 3 == 0 && number1 % 5 == 0){
4
+            return "FizzBuzz";
5
+        }else if(number1 % 3 == 0){
6
+            return "Fizz";
7
+        }else if(number1 % 5 == 0){
8
+            return "Buzz";
9
+        }else {
10
+            return "" + number1;
11
+        }
4 12
     }
5 13
 }

+ 16
- 119
src/test/java/FizzBuzzTest.java Целия файл

@@ -2,135 +2,32 @@ import org.junit.Assert;
2 2
 import org.junit.Test;
3 3
 
4 4
 public class FizzBuzzTest {
5
-    @Test
6
-    public void ifThreeAndFiveTest(){
7
-        // Given
8
-        int number1 = 15;
9
-        String expectedNumber = "FizzBuzz";
10
-        //When
11
-        String actualNumber = FizzBuzz.of(number1);
12
-        //then
13
-        Assert.assertEquals(expectedNumber, actualNumber);
14
-    }
15
-
16
-    @Test
17
-    public void ifThreeAndFiveTest2(){
18
-        // Given
19
-        int number1 = 300000000;
20
-        String expectedNumber = "FizzBuzz";
21
-        //When
22
-        String actualNumber = FizzBuzz.of(number1);
23
-        //then
24
-        Assert.assertEquals(expectedNumber, actualNumber);
25
-    }
26
-
27
-    @Test
28
-    public void ifThreeAndFiveTest3(){
29
-        // Given
30
-        int number1 = -3000;
31
-        String expectedNumber = "FizzBuzz";
32
-        //When
33
-        String actualNumber = FizzBuzz.of(number1);
34
-        //then
35
-        Assert.assertEquals(expectedNumber, actualNumber);
36
-    }
37
-
38
-    @Test
39
-    public void ifThreeTest(){
40
-        // Given
41
-        int number1 = 99;
42
-        String expectedNumber = "Fizz";
43
-        //When
44
-        String actualNumber = FizzBuzz.of(number1);
45
-        //then
46
-        Assert.assertEquals(expectedNumber, actualNumber);
47
-    }
48
-
49
-    @Test
50
-    public void ifThreeTest2(){
51
-        // Given
52
-        int number1 = 6;
53
-        String expectedNumber = "Fizz";
54
-        //When
55
-        String actualNumber = FizzBuzz.of(number1);
56
-        //then
57
-        Assert.assertEquals(expectedNumber, actualNumber);
58
-    }
59
-
60
-    @Test
61
-    public void ifThreeTest3(){
62
-        // Given
63
-        int number1 = -24;
64
-        String expectedNumber = "Fizz";
65
-        //When
66
-        String actualNumber = FizzBuzz.of(number1);
67
-        //then
68
-        Assert.assertEquals(expectedNumber, actualNumber);
69
-    }
70
-
71
-    @Test
72
-    public void ifFiveTest(){
73
-        // Given
74
-        int number1 = 25;
75
-        String expectedNumber = "Buzz";
76
-        //When
77
-        String actualNumber = FizzBuzz.of(number1);
78
-        //then
79
-        Assert.assertEquals(expectedNumber, actualNumber);
80
-    }
81
-
82
-    @Test
83
-    public void ifFiveTest2(){
84
-        // Given
85
-        int number1 = 5000;
86
-        String expectedNumber = "Buzz";
87
-        //When
88
-        String actualNumber = FizzBuzz.of(number1);
89
-        //then
90
-        Assert.assertEquals(expectedNumber, actualNumber);
91
-    }
92 5
 
93 6
     @Test
94
-    public void ifFiveTest3(){
95
-        // Given
96
-        int number1 = -95;
97
-        String expectedNumber = "Buzz";
98
-        //When
99
-        String actualNumber = FizzBuzz.of(number1);
100
-        //then
101
-        Assert.assertEquals(expectedNumber, actualNumber);
7
+    public void fizzTest (){
8
+        String expected = "Fizz";
9
+        String actual = FizzBuzz.count(9);
10
+        Assert.assertEquals(expected,actual);
102 11
     }
103 12
 
104 13
     @Test
105
-    public void ifNoneTest(){
106
-        // Given
107
-        int number1 = 0;
108
-        String expectedNumber = "0";
109
-        //When
110
-        String actualNumber = FizzBuzz.of(number1);
111
-        //then
112
-        Assert.assertEquals(expectedNumber, actualNumber);
14
+    public void BuzzTest(){
15
+        String expected = "Buzz";
16
+        String actual = FizzBuzz.count(10);
17
+        Assert.assertEquals(expected,actual);
113 18
     }
114 19
 
115 20
     @Test
116
-    public void ifNoneTest2(){
117
-        // Given
118
-        int number1 = -47;
119
-        String expectedNumber = "-47";
120
-        //When
121
-        String actualNumber = FizzBuzz.of(number1);
122
-        //then
123
-        Assert.assertEquals(expectedNumber, actualNumber);
21
+    public void FizzBuzzTest2(){
22
+        String expected = "FizzBuzz";
23
+        String actual = FizzBuzz.count(15);
24
+        Assert.assertEquals(expected,actual);
124 25
     }
125 26
 
126 27
     @Test
127
-    public void ifNoneTest3(){
128
-        // Given
129
-        int number1 = 574;
130
-        String expectedNumber = "574";
131
-        //When
132
-        String actualNumber = FizzBuzz.of(number1);
133
-        //then
134
-        Assert.assertEquals(expectedNumber, actualNumber);
28
+    public void numbertest(){
29
+        String expected = "19";
30
+        String actual = FizzBuzz.count(19);
31
+        Assert.assertEquals(expected,actual);
135 32
     }
136 33
 }