on Friday March 10 no late submissions Your job Translate the test scripts into unit tests in Visual Studio Test Scripts gt Unit Tests CREATE5 10 25 100 3 10 10 10 ID: 803057
Download The PPT/PDF document "A3 SENG 301 A3 Due at noon" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
A3
SENG 301
Slide2A3
Due at
noon
on
Friday,
March
10, no late
submissions
Your
job:
Translate
the
test scripts
into
unit tests in Visual Studio
Test Scripts --> Unit Tests
CREATE(5, 10, 25, 100; 3; 10; 10; 10)
CONFIGURE([0] "
Coke
", 250; "
water", 250; "stuff", 205)COIN_LOAD([0] 0; 5, 1)COIN_LOAD([0] 1; 10, 1)COIN_LOAD([0] 2; 25, 2)COIN_LOAD([0] 3; 100, 0)POP_LOAD([0] 0; "Coke", 1)POP_LOAD([0] 1; "water", 1)POP_LOAD([0] 2; "stuff", 1)INSERT([0] 100)INSERT([0] 100)INSERT([0] 100)PRESS([0] 0)EXTRACT([0])CHECK_DELIVERY(50, "Coke")UNLOAD([0] )CHECK_TEARDOWN(315; 0; "water", "stuff")
Create the vending machine
Instantiate the logic class
Do each step
…
A
ll as a unit test
Slide4You’ve already seen this in tutorial
[
TestClass
]
public class
TestCases { [TestMethod] public void FooTest() { … Assert.AreEqual(expectedValue, actualValue); }}^ Fails if the expected value does not match the actual value
Slide5You’ve already seen this in tutorial
[
TestClass
]
public class
TestCases { [TestMethod] [ExpectedException(typeof(AssertFailedException))] public void FooTest() { … Assert.Fail(); }}
^ Passes so long as the exception gets fired!
Slide6Tests
All your tests should PASS
For sequences of actions that should result in a pass, these should PASS
For sequences of actions that should result in a fail, put an
ExpectedException
attribute at the top of the method to indicate what exception should be thrown – this will make the test PASS (because the code you are driving did the right thing).
Slide7Hint
Don’t forget to add the Logic class