Upload
dara-dodson
View
21
Download
1
Embed Size (px)
DESCRIPTION
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) - PowerPoint PPT Presentation
Citation preview
Exercises Sample Application
Foreign Cash Exchange
2
Overview
3
Exercises Overview
4
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
5
Description Foreign Cash Exchange
Object Types Description
Branches of the bank
Name, Location, Opening Hours, Phone Number, Provided Currencies with actual Amounts
ATMs Location, Status, Brand, Type , Serial Number Provided Currencies with actual Amounts
Persons Name, Date of Birth, Email, List of Phone Numbers (Number, Type), List of Addresses (State, City, Street or PO Box, ZIP, Type)
Employees of bank
Like Persons, additionally
Task, Salary, SSN, Branch, Supervisor, …
Relation: Employees advise Customers
Addresses State, City, Street or PO Box, ZIP, Type
6
Description Foreign Cash Exchange (cont.)
Object Types Description
Customers of the bank
Customers can be Persons or Companies
Customer Nr, CostomerSince, Credit Rating
Persons as Customers
Like Persons and Customers
Companies as Customers
Like Customers, additionally
Address, Set of Representatives (Persons)
Accounts Account Nr, Account Type, Currency, Actual Amount, Start Date, End Date, List of Interest Rates, List of Transactions
7
Description Foreign Cash Exchange (cont.)
Object Types Description
Currency Orders Date and Time Stamp, Supplied Currency, Supplied Amount, Requested Currency, Requested Amount, Exchange Rate, Fee
Different Types of Curr. Orders
Payment as Cash, Credit Card, or Account
Account Payment Like Currency Order, additionally Account
Credit Card Payment
Like Currency Order, additionally
Card Nr, Card Organization, Expiration Date
Prepared Payment
Like Currency Order, additionally
Requestor Name, Requestor Email, Order Nr
8
Branch and ATM Class Model
FCE.ATM
BrandTypeSerialNrAddressCurrencyBalances
NameAddressPhoneOpensCloses
FCE.Branch
ATMs
Branch
0..*
1
9
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
10
Write set up and tear down methods when necessary.
Method Purpose
OnBeforeAllTests() Run before all tests.
OnAfterAllTests() Run after all tests.
OnBeforeOneTest() Run before each test.
OnAfterOneTest() Run after each test.
How To: Create a Unit Test Class (cont.)
11
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: Create a Unit Test Class (cont.)
12
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
13
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"
How To: Run Unit Tests (cont.)
14
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
15
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 above Class statement.include helper
Include file may contain #include statements to include other files.
16
Unit Testing Macros
Macro $$$AssertEquals(value1, value2, message)
Asserts value1=value2
Macro $$$AssertNotEquals(value1, value2, message)
Asserts value1'=value2
Macro $$$AssertStatusOK(status, message)
Asserts status is OK
Macro $$$AssertStatusNotOK(status, message)
Asserts status is not OK
17
Unit Testing Macros (cont.)
Macro $$$AssertTrue(condition, message)
Asserts condition is true
Macro $$$AssertNotTrue(condition, message)
Asserts condition is false
18
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