180 likes | 311 Views
Exercises Sample Application. Foreign Cash Exchange. Overview. Exercises Overview. Exercise 13. Homework: For the example scenario "Foreign Cash Exchange" develop an UML class diagram See description on next slides or in chapter 2 Work in groups of two (or three)
E N D
Exercises Sample Application Foreign Cash Exchange
Exercise 13 • Homework: For the example scenario "Foreign Cash Exchange" develop an UML class diagram • See description on next slides or in chapter 2 • Work in groups of two (or three) • Explain your solution to the class • Discuss the presented solution
Branch and ATM Class Model FCE.ATM FCE.Branch Brand Type SerialNr Address CurrencyBalances Name Address Phone Opens Closes ATMs 0..* Branch 1
How To: Create a Unit Test Class • Create new class that extends %UnitTest.TestCase. • Each class represents a test case. • Add methods named Test*. • Write test code. • Use macros to make assertions. • Add additional methods not named Test* for control or other purposes.
How To: Create a Unit Test Class (cont.) • Write set up and tear down methods when necessary.
How To: Create a Unit Test Class (cont.) • Compile class. • Optionally, export class (or classes) as XML file to subfolder of root testing folder. • Each subfolder of root testing folder represents a test suite. • Allows test classes to be loaded, compiled, run, and deleted in another namespace.
How To: Run Unit Tests • Run tests using %UnitTest.Manager class. do ##class(%UnitTest.Manager).RunTest(TestSpec,Qualifiers) • To run one test case (without XML file): • Arguments: • TestSpec = "TestSuiteFolder:TestCaseClass" • Qualifiers = "/noload/norecursive" • Without XML file, TestSuiteFolder is “organizational” only; used to navigate test results in browser. • Convention: same as TestCaseClass.
How To: Run Unit Tests (cont.) • Run tests using %UnitTest.Manager class. do ##class(%UnitTest.Manager).RunTest(TestSpec,Qualifiers) • To load an XML file, compile all its classes, run all tests, and delete all classes: • Argument: • TestSpec = "TestSuiteFolder" • Before running test, must also specify root folder for unit testing. set ^UnitTestRoot = "PathToContainingFolder"
ObjectScript Macros • Macro: named piece of ObjectScript code, usually defined at top of method. #define sum x+y • Macro may take arguments (%* variables). #define sumplusextra(%extra) x+y+%extra • When writing method, use macro by preceding name with $$$. set x=4, y=5, s=$$$sum, b=$$$sumplusextra(6) • Compiler replaces macro with code. set x=4, y=5, s=x+y, b=x+y+6
Include (INC) files • File containing several #define statements. For example, helper.inc: #define sum x+y #define sumplusextra(%extra) x+y+%extra • Including file in class definitions provides all macros. • Use IncludeCode attribute of class, or enter aboveClass statement. include helper • Include file may contain #include statements to include other files.
Exercise 14 Description: As class … • define specification for class Branch • create unit test class for initial FCE application • define OOP unit tests for Branch (demonstration) In your team … • define specification for class ATM • define OOP unit tests for ATM