Stwillia94 6 년 전
부모
커밋
c9a833bdf4
2개의 변경된 파일123개의 추가작업 그리고 2개의 파일을 삭제
  1. 66
    1
      src/main/java/FizzBuzz.java
  2. 57
    1
      src/test/java/FizzBuzzTest.java

+ 66
- 1
src/main/java/FizzBuzz.java 파일 보기

@@ -1,2 +1,67 @@
1
+
1 2
 public class FizzBuzz {
2
-}
3
+
4
+
5
+    public String testThree(int i) {
6
+        if (i % 3 == 0){
7
+            return "Fizz";
8
+        }
9
+        return String.valueOf(i);
10
+    }
11
+
12
+
13
+
14
+
15
+
16
+    public String testFive(int i) {
17
+        if ( i % 5 == 0){
18
+            return "Buzz";
19
+
20
+        }
21
+        return String.valueOf(i);
22
+
23
+    }
24
+
25
+
26
+
27
+
28
+    public String testThreeFive(int i) {
29
+        if (i % 15 == 0){
30
+            return "FizzBuzz";
31
+
32
+        }
33
+        return String.valueOf(i);
34
+
35
+    }
36
+
37
+
38
+
39
+
40
+
41
+    public String testNeither(int x) {
42
+        return String.valueOf(x);
43
+    }
44
+
45
+
46
+    public String fizzBuzzChecker(int x) {
47
+        if (x % 15 == 0) {
48
+            return "FizzBuzz";
49
+        }
50
+        else if (x % 3 == 0) {
51
+            return "Fizz";
52
+
53
+        }
54
+        else if (x % 5 == 0){
55
+            return "Buzz";
56
+        }
57
+        else {
58
+            return String.valueOf(x);
59
+        }
60
+    }
61
+
62
+    }
63
+
64
+
65
+
66
+
67
+    

+ 57
- 1
src/test/java/FizzBuzzTest.java 파일 보기

@@ -1,2 +1,58 @@
1
-public class FizzBuzzTest {
1
+import org.junit.Assert;
2
+import org.junit.Before;
3
+import org.junit.Test;
4
+
5
+public class FizzBuzzTest
6
+{
7
+    FizzBuzz fizzBuzz;
8
+
9
+    @Before
10
+    public void setup(){
11
+        fizzBuzz = new FizzBuzz();
12
+    }
13
+
14
+    @Test
15
+    public void testThree(){
16
+        // Given
17
+        String expected = "Fizz";
18
+
19
+        //When
20
+        String actual = fizzBuzz.fizzBuzzChecker(3);
21
+
22
+        //Then
23
+        Assert.assertEquals(expected, actual);
24
+    }
25
+
26
+
27
+    @Test
28
+    public void testFive(){
29
+        // Given - setup
30
+
31
+        String actual = fizzBuzz.fizzBuzzChecker(5);
32
+
33
+        String expected = "Buzz";
34
+        Assert.assertEquals(expected, actual);
35
+    }
36
+
37
+    @Test
38
+    public void testThreeFive() {
39
+        // Given - setup
40
+
41
+        String actual = fizzBuzz.fizzBuzzChecker(15);
42
+
43
+        String expected = "FizzBuzz";
44
+        Assert.assertEquals(expected, actual);
45
+    }
46
+
47
+    @Test
48
+    public void testNeither() {
49
+        // Given - setup
50
+
51
+        String actual = fizzBuzz.fizzBuzzChecker(2);
52
+
53
+        String expected = "2";
54
+        Assert.assertEquals(expected, actual);
55
+    }
56
+
57
+
2 58
 }