|
@@ -1,28 +0,0 @@
|
|
|
-package cn.qinys.learn.creational.factory;
|
|
|
|
|
-
|
|
|
|
|
-import org.junit.jupiter.api.Test;
|
|
|
|
|
-import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
|
-
|
|
|
|
|
-public class FruitFactoryTest {
|
|
|
|
|
-
|
|
|
|
|
- @Test
|
|
|
|
|
- public void testCreateApple() {
|
|
|
|
|
- Fruit fruit = FruitFactory.createFruit("apple");
|
|
|
|
|
- assertTrue(fruit instanceof Apple);
|
|
|
|
|
- fruit.grow(); // Should print "Apple is growing"
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Test
|
|
|
|
|
- public void testCreateBanana() {
|
|
|
|
|
- Fruit fruit = FruitFactory.createFruit("banana");
|
|
|
|
|
- assertTrue(fruit instanceof Banana);
|
|
|
|
|
- fruit.grow(); // Should print "Banana is growing"
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Test
|
|
|
|
|
- public void testCreateUnknownFruit() {
|
|
|
|
|
- assertThrows(IllegalArgumentException.class, () -> {
|
|
|
|
|
- FruitFactory.createFruit("orange");
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|