Beginning C# Programming with MonoGame by Chamillard A.T
Author:Chamillard, A.T. [Chamillard, A.T.]
Language: eng
Format: mobi
Publisher: Burning Teddy
Published: 2015-11-15T16:00:00+00:00
Figure 12.5. Die UML Diagram
Since we've now finished our UML diagram, we're ready to move on to our test plan.
Write Test Cases
We need to make sure our test plan covers both constructors, the TopSide and NumSides properties, and the Roll method. We don't have any selection or iteration constructs in any of this, so we could do all the testing in a single test case, but let's do one test case for the default six-sided die and another for a 256-sided die. For each of the test cases, we'll get the top side and the number of sides right after creating the die, then roll the die 3 times and print the resulting top side of the die after each roll. These test cases are really unit test cases since we’re testing a single class rather than functional test cases.
Test Case 1
Checking 6-Sided Die
Step 1. Input: None. Hard-coded steps in the test case code
Expected Result:
Top Side: 1
Num Sides: 6
Top Side: appropriate
Top Side: appropriate
Top Side: appropriate
Notice that we have a new problem here because we’re trying to test a program that uses random numbers. How are we going to tell whether or not the top side is correct after each roll? This is actually a really hard problem to solve. At this point, we’ll just confirm that the rolls “look random”, though we recognize this is an imperfect approach. We’ll discuss this further at the end of the chapter.
Here's the other test case:
Test Case 2
Checking 256-Sided Die
Step 1. Input: None. Hard-coded steps in the test case code
Expected Result:
Top Side: 1
Num Sides: 256
Top Side: appropriate
Top Side: appropriate
Top Side: appropriate
Write the Code
Let's write the constructor that doesn't have any parameters and the TopSide and NumSides properties and test those out before writing the Roll method. Our initial code is in Figure 12.6.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12566)
Hello! Python by Anthony Briggs(9911)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9794)
The Mikado Method by Ola Ellnestam Daniel Brolund(9775)
Dependency Injection in .NET by Mark Seemann(9335)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8293)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7758)
Grails in Action by Glen Smith Peter Ledbrook(7693)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7025)
Microservices with Go by Alexander Shuiskov(6791)
Practical Design Patterns for Java Developers by Miroslav Wengner(6704)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6646)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6409)
Angular Projects - Third Edition by Aristeidis Bampakos(6053)
The Art of Crafting User Stories by The Art of Crafting User Stories(5585)
NetSuite for Consultants - Second Edition by Peter Ries(5517)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5320)
Kotlin in Action by Dmitry Jemerov(5061)
