source: java/main/src/test/java/com/framsticks/model/CreatureTest.java @ 193

Last change on this file since 193 was 193, checked in by Maciej Komosinski, 10 years ago

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1package com.framsticks.model;
2
3import org.testng.annotations.Test;
4
5import com.framsticks.params.FramsClass;
6import com.framsticks.params.ReflectionAccess;
7import com.framsticks.params.types.ArrayListParam;
8import com.framsticks.params.types.DecimalParam;
9import com.framsticks.params.types.StringParam;
10import com.framsticks.test.TestConfiguration;
11
12import static org.fest.assertions.Assertions.*;
13import static com.framsticks.params.ParamsUtil.getParam;
14
15@Test
16public class CreatureTest extends TestConfiguration {
17
18        FramsClass framsClass;
19        ArrayListParam partsParam;
20        ReflectionAccess access;
21        Creature creature;
22
23        @Test
24        public void testFramsClass() {
25                framsClass = FramsClass.build().forClass(Creature.class);
26
27                assertThat(framsClass).describedAs("framsClass").isNotNull();
28                assertThat(framsClass.getParam("name")).describedAs("name").isInstanceOf(StringParam.class);
29                assertThat(framsClass.getParam("parts")).describedAs("parts").isInstanceOf(ArrayListParam.class);
30                partsParam = getParam(framsClass, "parts", ArrayListParam.class);
31                assertThat(partsParam).describedAs("partsParam").isNotNull();
32                assertThat(partsParam).isInstanceOf(ArrayListParam.class);
33                assertThat(partsParam.getContainedTypeName()).isEqualTo("Part");
34                assertThat(framsClass.getParam("gnum")).isInstanceOf(DecimalParam.class);
35        }
36
37        @Test(dependsOnMethods = "testFramsClass")
38        public void testReflectionAccess() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
39                access = new ReflectionAccess(Creature.class, framsClass);
40                Object object = access.createAccessee();
41                assertThat(object).isInstanceOf(Creature.class);
42                access.select(object);
43
44                creature = (Creature) object;
45                access.set("gnum", new Integer(1));
46                // Creature.class.getField("generation").set(creature, 1);
47                assertThat(creature.generation).isEqualTo(1);
48
49
50        }
51
52
53
54}
Note: See TracBrowser for help on using the repository browser.