EventBuilder Tests
This commit is contained in:
parent
7dcffab0a6
commit
940d8a8d97
@ -2,5 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/Gamelib" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -218,15 +218,78 @@ class EventBuilderTest {
|
||||
}
|
||||
|
||||
// TODO: implement tests for unchecked CharacterEvents and EntityEvents
|
||||
@Test
|
||||
void buildWrongEntityEvent1() {
|
||||
EventBuilder eb = new EventBuilder(EventType.DestroyedEntityEvent);
|
||||
//the target entity is not set
|
||||
EntityEvent des2 = eb
|
||||
.withTargetField(new IntVector2(1,1))
|
||||
.buildEntityEvent();
|
||||
//the target entity is not set --> check() return false
|
||||
boolean b = des2.check();
|
||||
assertEquals(b, false);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildEntityEvent() {
|
||||
// TODO: check all entityEvent type validations for correctness
|
||||
//testing EntityEvent class
|
||||
assertThat(new EventBuilder(EventType.DestroyedEntityEvent)
|
||||
.withTargetField(new IntVector2(1,1))
|
||||
.withTargetEntity(new EntityID(EntityType.P1,1))
|
||||
.buildEntityEvent().check()).isTrue();
|
||||
|
||||
EntityEvent des = new EntityEvent();
|
||||
des.type = EventType.DestroyedEntityEvent;
|
||||
des.targetEntity= new EntityID(EntityType.P1,1);
|
||||
des.targetField= new IntVector2(1,1);
|
||||
|
||||
EventBuilder eb = new EventBuilder(EventType.DestroyedEntityEvent);
|
||||
EntityEvent des2 = eb
|
||||
.withTargetField(new IntVector2(1,1))
|
||||
.withTargetEntity(new EntityID(EntityType.P1,1))
|
||||
.buildEntityEvent();
|
||||
|
||||
//testing EventBuilder
|
||||
assertEquals(des.type, des2.type);
|
||||
assertEquals(des.targetEntity, des2.targetEntity);
|
||||
assertEquals(des.targetField, des2.targetField);
|
||||
// EntityEvent des2 = new EntityEvent(eb.);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildCharacterEvent() {
|
||||
// TODO: check all characterEvent type validations for correctness
|
||||
//testing CharacterEvent class
|
||||
assertThat(new EventBuilder(EventType.MeleeAttackEvent)
|
||||
.withOriginField(new IntVector2(2,2))
|
||||
.withTargetField(new IntVector2(1,1))
|
||||
.withOriginEntity(new EntityID(EntityType.P2,2))
|
||||
.withTargetEntity(new EntityID(EntityType.P1,1))
|
||||
.buildEntityEvent().check()).isTrue();
|
||||
|
||||
CharacterEvent des = new CharacterEvent();
|
||||
des.type = EventType.MeleeAttackEvent;
|
||||
des.originField= new IntVector2(2,2);
|
||||
des.targetEntity= new EntityID(EntityType.P1,1);
|
||||
des.originEntity = new EntityID(EntityType.P2,2);
|
||||
des.targetField= new IntVector2(1,1);
|
||||
|
||||
EventBuilder eb = new EventBuilder(EventType.MeleeAttackEvent);
|
||||
CharacterEvent des2 = eb
|
||||
.withOriginField(new IntVector2(2,2))
|
||||
.withTargetField(new IntVector2(1,1))
|
||||
.withOriginEntity(new EntityID(EntityType.P2,2))
|
||||
.withTargetEntity(new EntityID(EntityType.P1,1))
|
||||
.buildCharacterEvent();
|
||||
//testing EventBuilder
|
||||
assertEquals(des.type, des2.type);
|
||||
assertEquals(des.targetEntity, des2.targetEntity);
|
||||
assertEquals(des.targetField, des2.targetField);
|
||||
assertEquals(des.originEntity, des2.originEntity);
|
||||
assertEquals(des.originField, des2.originField);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -269,6 +332,24 @@ class EventBuilderTest {
|
||||
|
||||
@Test
|
||||
void buildCustomEvent() {
|
||||
// TODO: check CustomEvent validation for correctness
|
||||
//testing CustomEvent class
|
||||
assertThat(new EventBuilder(EventType.CustomEvent)
|
||||
.withCustomContent(new HashMap<String, Object>())
|
||||
.buildCustomEvent().check()).isTrue();
|
||||
|
||||
CustomEvent des = new CustomEvent();
|
||||
des.type = EventType.CustomEvent;
|
||||
des.customContent= new HashMap<String, Object>();
|
||||
|
||||
|
||||
EventBuilder eb = new EventBuilder(EventType.CustomEvent);
|
||||
CustomEvent des2 = eb
|
||||
.withCustomContent(new HashMap<String, Object>())
|
||||
.buildCustomEvent();
|
||||
|
||||
//testing EventBuilder
|
||||
assertEquals(des.type, des2.type);
|
||||
assertEquals(des.customContent, des2.customContent);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user