Wednesday, July 22, 2009

Pex and XNA

(July 12th - July 18th)

Had another meeting with Dr. Xie about the unit testing using Pex with my game. I didn't have a good test (I need to write more unit tests with Pex to get tightly controlled test). Over the week I kept looking at the code and it seems that the way that the parameter is used and the way Pex uses parameters seems to have some conflict.

The class/method is:
public class Entity
{
...
public void handle_collision(MapEngine e)
{ ...}
...
}

The method basically handles the collision of the Map and the entity using it. Inside the method, if the position of the entity's collision box intersects with the a "wall" on the map, the entity's collision state changes to being hit and the entity's position is moved.

Now the problem is that the MapEngine object is only used as a reference for the character to see where it is on the map. It doesn't "change" per se, it only changes which map is the current map (and it has references to the previous and next map if any). The map itself doesn't change, the thing that does, is the entity's position. Depending on the position of the entity on the current map, it will collide or not, not depending on the current map.

The problem with Pex is that it uses different inputs to get high code coverage. In this case, the MapEngine is pretty much static in that the map is not changing everytime the method is called but the position of the entity is (and it is automatically changed in another method). If the input was the position value, then Pex would be able to test it. In order for collision detection in my game to work and for Pex to analyze it, I would have to change the implementation significantly. I am going to write up a thorough explanation of my problem to Dr. Xie next week and also test to see if there is anything I could do without having to test just in case I missed something.

1 comment:

  1. I was shocked to see the word PEX being related to a technology, i was under an impression that its related to plumbing....lol

    ReplyDelete