Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6
This is the forum to discuss the Wrox book Professional XNA Game Programming: For Xbox 360 and Windows by Benjamin Nitschke; ISBN: 9780470126776
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 20th, 2007, 11:58 PM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Where are all the unit tests?

Hi,

One of the reasons I bought the book is because of Benjamin's emphasis on unit tests...but in the first four chapters of the code, I cannot find the unit test class.

For example, in chapter 4, TestGame is the class responsible for the unit tests. Alas, nowhere in the book is the code for TestGame shown, and TestGame cannot be found inside the downloaded code.

Did I miss something?

  #2 (permalink)  
Old July 17th, 2007, 05:39 PM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It is in the TestGame.cs file in the Game folder in the source code.

There is a BaseGame class which does things that need to happen in the unit test environment and in the full game. For example the code to get the screen resolution and remember it is in the Initialize() method of the BaseGame class. The TestGame class and the main game class inherit from this so do not need do this themselves.

The TestGame class does very little and makes it useful to isolate the one part of your code you are testing. The idea is, you store the code you want to test in a delegate (a type of object that can hold code), call the TestGame.Start() method and it then creates the stripped down TestGame class for you but remembers the code you passed in so that it can be ran during the Draw() method of the TestGame class.

Read through it and it will make more sense. A good one is the TestBackgroundBoxes test in the TetrisGame.cs file in Chapter 4's source. Then look at the TestGame.Start() method in TestGame.cs, look at the constructor on line 41 and finally look at the Draw method in that file. The program.cs file shows how you choose between tests.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Failing DAO Tests dgalehouse BOOK: Beginning Spring Framework 2 ISBN: 978-0-470-10161-2 13 September 28th, 2009 07:13 PM
Chapter 2 AD HOC Testdriven.net tests? phsarjk BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 1 May 17th, 2007 04:12 PM
PHP Editor: beta tests Luckasoft Pro PHP 2 March 13th, 2005 09:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.