1package test.factory;
2
3import org.testng.Assert;
4import org.testng.annotations.Factory;
5import org.testng.annotations.Test;
6
7public class GitHub876Sample {
8
9    @Factory
10    public Object[] createInstances() {
11        return new Object[]{
12                new GitHub876Sample(new DataTest("foo", true)),
13                new GitHub876Sample(new DataTest("FOO", false))
14        };
15    }
16
17    private final DataTest dataTest;
18
19    public GitHub876Sample(DataTest dataTest) {
20        this.dataTest = dataTest;
21    }
22
23    @Test
24    public void test() {
25        switch (dataTest.s) {
26            case "FOO":
27                Assert.assertFalse(dataTest.b);
28                break;
29            case "foo":
30                Assert.assertTrue(dataTest.b);
31                break;
32            default:
33                Assert.fail("Unknown value");
34        }
35    }
36
37    public static class DataTest {
38
39        private final String s;
40        private final boolean b;
41
42        public DataTest(String s, boolean b) {
43            this.s = s;
44            this.b = b;
45        }
46    }
47}
48