Your SlideShare is downloading. ×
Hierarchical Project Management System
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Hierarchical Project Management System

1,159

Published on

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,159
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. CSIE/NTUT Object-Oriented Analysis and Design Hierarchical Project Management System The homework #5 (Post-Mid-Review Ed.) for Object-Oriented Analysis Design Course, Spring 2006. Written by Chang, Chuan-Wen (#94419012)
  • 2. OOAD Homework (Spring 2006) 1
  • 3. TABLE OF CONTENTS 1. REQUIREMENT DOCUMENT ......................................................................................4 1.1 Revision History 4 1.2 Problem Statement 6 1.3 System Context Diagram 7 1.4 Summary of System Features 8 1.5 Use Cases 9 1.5.1 Use Cases Diagram 9 1.5.2 User Authentication and Authorization 10 1.5.3 Management Users 10 1.5.4 Register Project 11 1.5.5 Manage Project 12 1.5.6 Feedback Task Execution Status 13 1.5.7 Information Reporting 14 1.6 Non-Functional Requirements and Constraints 15 1.7 Data Dictionary 16 1.8 Software Environment 17 2. DOMAIN CLASS MODEL...........................................................................................18 2.1 Domain Class Model Showing Only Concepts 18 2.2 Add Associations 19 2.3 Add Attributes 21 3. CLASS DESIGN.........................................................................................................22 3.1 Use-Case Realizations with GRASP Patterns 22 3.1.1 Choose the most significant use-case, identify system events, and draw a system sequence diagram for that use case. 22 3.1.2 Write a contract for each system operation (system event). 24 3.1.3 Draw a sequence diagram for each system event you identified, and label with the GRASP patterns to describe how you assign responsibilities. 25 3.2 Design Class Model 29 5. IMPLEMENTATION CLASS MODEL.........................................................................30 5.1 Draw an implementation class diagram for your system (including associations, attributes and methods) 30 5.2 Show the difference between implementation class model and design class model 31 5.3 Calculate Line of Code 32 6. PROGRAMMING ......................................................................................................33 6.1 Snapshots of system execution (optional) 33 6.2 Source Code Listing 34 OOAD Homework (Spring 2006) 2
  • 4. 7. UNIT TESTING ........................................................................................................45 7.1 Snapshots of testing result (optional) 45 7.2 Unit Testing Code Listing 45 OOAD Homework (Spring 2006) 3
  • 5. 1. REQUIREMENT DOCUMENT 1.1 Revision History Date Major Modifications Summary Measurement Mar 6, 2006 Problem statement drafted, Total 3 hours Homework #1 published Mar 22, 2006 Document format revised, 06/03/19 15:00~ 06/03/19 17:30 System context diagram drafted, 06/03/22 13:15~ Summary of System Feature drafted, 06/03/22 15:45 Use Case Diagram drafted, 06/03/22 18:30~ Use Case drafted, 06/03/22 21:00 Non-functional and constraints Total 7.5 hours drafted, Data Dictionary drafted, Software Environment drafted, Homework #2 published Mar 24, 2006 Bug-correct to Use Case Diagram 06/03/24 12:15 06/03/24 12:30 Homework #2 re-published Total 0.25 hour Apr 04, 2006 Document format and content revised 06/04/04 15:00 to (recommended by TA) 06/04/04 19:30 Apr 05, 2006 New Use case (UC-04, UC-05, UC-06) 06/04/04 21:00 drafted. 06/04/04 22:30 Domain Class Model Showing Only 06/04/05 19:00 Concepts drafted. 06/04/05 23:00 Add Associations drafted. Total 10 hours Homework #3 published Apr 19, 2006 Use-Case Realizations with GRASP 06/04/19 19:00 to Patterns drafted 06/04/19 22:00 Apr 21, 2006 Design Class Model drafted 06/04/20 19:00 06/04/21 03:30 Homework #4 published 06/04/21 13:00 OOAD Homework (Spring 2006) 4
  • 6. 06/04/21 17:30 Total hours 16 hours May 7, 2006 Add some description on project 06/05/07 16:00 to manager's benefits (by provides a 06/05/07 17:30 May 9, 2006 global view to the managed projects) 06/05/07 22:00 in project statement section. 06/05/08 05:00 More information to the System 06/05/08 21:00 Context Diagram. 06/05/09 06:00 Merge UC-02-01 and UC-02-02 into 06/05/09 13:00 UC-02 User Management use case 06/05/09 16:30 Change some use-cases' name with 06/05/09 19:30 the format of “verb+noun” 06/05/09 20:30 In each contracts, Change the Total 20 hour "System" into "System Controller" to avoid confusing. Remove all interfaces in the User Interface to avoid define the interface precisely during design phase. UC-04 Implementation & Unit-testing OOAD Homework (Spring 2006) 5
  • 7. 1.2 Problem Statement Project Management System (PMS) had been widely used in organizations which allow everyone (include Project Manager or Project Member) related to the project can get the most up-to-date information anytime, anywhere. Project Management is not only useful in software development, but also in many mature processes, such as building a house or bridge. Many years ago, the age without software, project management was done through pen and paper. Project Managers wrote down their design and task required in order to finish their final goal, and used traditional way such as getting the project task status by phone or mail. However, it’s hard to get a whole view of the entire project. With the support of IT technology, it is not difficult to implement an online PMS to support those real-time project management activities. A Project is an information collection which includes general information such as Project Title, Proprietor, Start Date and Finish Date, etc, and a number of related tasks in order to finish the project which planned by a people who is in charge on the project, called Project Manager. A Task usually assign to a people (usually called project members) who is familiar with it. For management purposes, a task usually includes a Task Title which describes the task, a Resource about the team member assigned to the task, a Task Start Date and a Task Finish Date which indicate the time of the task started and finished actually. Other information may also be logged into task information which could aim on advance analysis activities such as process performance analysis to project members. Compare to most of the PMS systems available today, this system should provide an extra support on large projects. A large project mentioned here indicates a long-term or multi-phase project which may be controlled by several project managers. Like a normal, regular project, a large project itself will be assigned a project manager for overall project planning. Additionally, the project manager may separate this large project (usually called Parent Project) into some smaller projects (usually called Child Projects) and assign different project managers for those smaller projects. The relationship between the parent project and child projects is called “Hierarchical”. In conclusion, the project separation has already been a practical strategy and adapted in enterprises already but not widely supported by most PMS available today. A major purpose of this Hierarchical Project Management System (HPMS) is designed to provide a system which could handle this situation. Like most project management system today, the HPMS provides a view to project managers about the actual task executing status based on the task executing results which feedback by those project members. Moreover, HPMS also provides a global view to those project managers who manage many small projects through integrated information which aggregated with every tasks status from every small projects. OOAD Homework (Spring 2006) 6
  • 8. 1.3 System Context Diagram Figure 1 shows the System Contet Diagram of this Hierarchical Project Management System. Browser in Employee's Workstation Project Manager Browser in Central Browser in Employee's Management IT staff's Workstation System Workstation Project Member Administrator Web Server & Storage System Boundary Browser in Remote Users' Workstation Remote Users Not included during the first phase Figure 1, The System context diagram of the Hierarchical Project Management System Deploy this system to an environment which including employees’ workstations (used by project manager and project member) and IT staffs’ workstations within the coporate network—the corpNet (might be extended to across the Internet in the future). The administrator use it’s workstation (located in MIS department, denoted in “IT staff’s workstation”; Other regular users include project managers and members use their laptop which denoted in “Employee’s Workstation” to access the “Central Management System”, which hosted in headquarter’s server room. The Central Management System provides central host applications and a storage for PMS system, regular users and administrator access this system through those applications hosted in Central Management System. Each user of this system which identified by their ID and role will got a set of system functions, to support their responsibilities of project amangement. OOAD Homework (Spring 2006) 7
  • 9. 1.4 Summary of System Features The following system features is identified as following items. Feature ID Feature Descriptions FEA-01 All user should identify theirelf in order to use any feature of this system. FEA-02 Separation of responsibilities. Depends on the the role of current user, only limited functions available could be accessed. FEA-03 Support Project-Tasks (1 to many) project management relationship FEA-04 Support Master Project-Child Projects (1 to many) project Management relationship FEA-05 Provides project-level information reporting for each Project Manager for management and audit purpose. FEA-06 Web-based system architecture, allow all system users can access this system, anytime, everywhere (within corpNet) FEA-07 Use text file (XML) as primary storage, no RDBMS is required for this system. OOAD Homework (Spring 2006) 8
  • 10. 1.5 Use Cases 1.5.1 Use Cases Diagram Hierarchical Project Management System (HPMS) User Authentication and Authorization Administrator Manage Users Register Project Manage Project Project Manager Feedback Task Execution Status Information Reporting Project Member Figure 2, The Use Case Diagram for Hierarchical Project Management System Those use cases identified this time are listed in the following table. Use Case ID Use Case UC-01 User Authentication and Authorization UC-02 Manage Users UC-03 Register Project OOAD Homework (Spring 2006) 9
  • 11. UC-04 Manage Project UC-05 Feedback Task Execution Status UC-06 Information Reporting 1.5.2 User Authentication and Authorization Use Case ID UC-01 Summary A user get authenticated and authorized by his/her id and password, and then could access a predefined function set, depends on his/her role associated. Primary Actor User Precondition n/a Description 1. A user accesses this system through a workstation in the corpNet. 2. The user enters his/her identification to login this system. 3. System logs his/her name, current time into the system access log. 4. System shows a list of functions accessible by the user, determined by this/her role. Exception 2a: System responses an error message when the identification provided by the user not exists in system’s user database. Post Condition User is gain access to this system, and can access any function granted by this system. 1.5.3 Management Users Use Case ID UC-02 Summary A user with administrator permission creates a new user account for the system. Primary Actor Administrator OOAD Homework (Spring 2006) 10
  • 12. Precondition A user belongs to “administrator” role had already login to this system. Description 1. The administrator accesses the “User Maintenance” function. 2. System shows a user list current exists in the user database. 3. The administrator starts the “Create a User”, the “Update a User”, or the “Delete a User” action. 3a. Administrator creates a new user with the new user’s name, credential (a unique logon id and password), and the role will be play by the new user. 3b. Administrator update an existing user’s information with the user’s, credential (a unique logon id and password), and the role will be play by the existing user. 3c. Administrator delete an current user by enter the user’s name. 4. System response an confirmation message to the administrator. Exception 4a: System responses an error message when the user id was duplicated with other user in system’s user database. 4b: System responses an error message when the user name, user id had not entered. Post Condition A new user account will be saved in the system’s user database after this operation success. 1.5.4 Register Project Use Case ID UC-03 Summary A user with administrator permission registers a new project to the system. Primary Actor Administrator Precondition A user belongs to “administrator” role had already login this system. Description 1. The administrator accesses the “Project Registration” OOAD Homework (Spring 2006) 11
  • 13. function to start a project registration. 2. The administrator enters a project id, the name, description, started date and finished date of the new project. 3. The administrator may also assign a project manager to this new project. A project manager is a user with “Project Manager” role. 4. The administrator save this new project into system. Exception 2a: System responses an error message when the project id is duplicated with other project in system’s project database. 2b: System responses an error message when the project id, project name, start date, or end date had not entered. Post Condition The new project will be registered to the system’s project database after this operation success. 1.5.5 Manage Project Use Case ID UC-04 Summary A user with project manager permission manages the project which already assign to him/her. Primary Actor Project Manager Precondition A user belongs to “Project Manager” role had already login this system. Description 1. The project manager accesses the “Manage Project” function to start a project management. 2. The system returns a list contains projects which already assigned to him/her. 3. The project manager picks a project. 4. The project manager manages the picked project. 4a. Split a project into some child projects: 1. The project manager separates this project into some smaller projects. Those smaller projects can be treated as standalone OOAD Homework (Spring 2006) 12
  • 14. projects (project) 2. Project manger assigns a unique project id and name, and a project manager for those new child projects. 4b. Manage Tasks: 1. The project manager divides this project into several tasks. 2. Each task information includes a task name, started date, finished date, and a task owner who associated a project member role. 5. The project manager save the process results. Exception 2a: System responses an error message and terminates this case when no any project contains in the return list. Post Condition New child projects or project tasks will be stored into this system after this operation success. 1.5.6 Feedback Task Execution Status Use Case ID UC-05 Summary A user with project member permission feedback the task execution status of a task assigned to him/her.. Primary Actor Project Member Precondition A user belongs to “project member” role had already login this system. Description 1. The project member accesses the “Task Execution Status Feedback” function to start a Status Feedback. 2. The system returns a tasks list grouped by project which already had assigned to him/her, which contains tasks which already assigned to him/her. 3. The project member picks a task. 4. The project member feedback the task execution status to the picked task by enters actual started date, actual finished date, the number of line of code and the number of classes created. OOAD Homework (Spring 2006) 13
  • 15. 5. The project member saves this task executing status. Exception 2a: System responses an error message and terminates this case when no any task contains in the return list. Post Condition The task executing results will be stored into this system after this operation success. 1.5.7 Information Reporting Use Case ID UC-06 Summary A user with project manager permission queries the overall project executing results to the projects which already assigned to him/her. Primary Actor Project Manager Precondition A user belongs to “Project Manager” role had already login this system. Description 1. The project manager accesses the “Task Information Reporting” function to start an information reporting. 2. The system returns a list which contains projects which already assigned to him/her. 3. The project manager picks a project. 4. The system displays all tasks information belongs to the picked project. Those tasks should be sorted by the task start date; if the picked project is a master project, those tasks information should be sorted by child project first, then by the task start date in same child project. Each task information should includes task name, started date, finished date, actual started date, actual finished date, the number of line of code and the number of classes created. Exception 2a: System responses an error message and terminates this case when no any project contains in the return list. Post Condition n/a OOAD Homework (Spring 2006) 14
  • 16. 1.6 Non-Functional Requirements and Constraints The non-functional functional requirements and any constraint identified currently is listed in the follows. NFR ID Category Description NFR-01 Security All user’s operation should be logged in system’s access log. NFR-02 Availability This system should provide non-stop service during 9 to 5 in every regular working days. NFR-03 Supportability This helpdesk of this system could feedback first response within 1 hour after a request received. NFR-04 Dev. Tools This system should be developmented based on on Microsoft’s Windows Platform and .Net technology. NFR-05 Dev. Tools No any RDBMS (such as Microsoft SQL Server) could be used within this system. OOAD Homework (Spring 2006) 15
  • 17. 1.7 Data Dictionary Term Definition or Description Administrator Represents a user with administrator role associated. A user with administrator permission usually performs system-wide operations such as user management and project registration. Child Project See Project Master Project See Project Project A project used here is represent a completed work coorsponding to a business contract. A project should be assigned a project manager for task planning, resource planning and progress monitoring. A project could associated with a number of tasks in order to fulfill the contract’s requirements. Sometimes a large project (called Master Project) could separate into some smaller projects (called Child Project) for better manageability. Project Manager Represents a user with project manager role associated. A user with project manager permission usually performs project-wide operations such as project separation and resource allocation. Project Member Represents a user with project member role associated. A user with project member permission usually performs task-wide operations such as task execution status feedback. Role; User Role Role, or User Role represents one of system defined permissions. A role could be associated to a user, this indicates a user is granted a set of permission which defined with the specific role. There are three system-defined roles including administrator”, project manager and project member. Task A Task is a unique job to be completed for a specific project. User A user is a basic concept of valid system users. With some authorization, a user can be associated with one or many system-define roles (see Role) to perform their jobs. (Listed in alphabetic order) OOAD Homework (Spring 2006) 16
  • 18. 1.8 Software Environment Software Platform: Microsoft Windows Server 2003+ Development language/Tool: Microsoft C# and other Microsoft .Net Technonology (such as ASP.Net) will be used, and the major development tool will be Microsoft Visual Studio.Net. OOAD Homework (Spring 2006) 17
  • 19. 2. DOMAIN CLASS MODEL 2.1 Domain Class Model Showing Only Concepts Figure 3, HPMS Classes identified Figure 4, Eliminateing unnecessary classes OOAD Homework (Spring 2006) 18
  • 20. 2.2 Add Associations Verb phases System generates List of Functions List of Functions contains Functions System generates Project List System generates Task List System generates User List User List consists of Administrators, Project Managers, and Project Members An Administrator creates other Administrators, Project Managers, and Project Members Administators, Project Managers, and Project Members read List of Functions An Administrator creates Projects Project Manager manages projects A Project (master project) separates into some projects (child project) A Project contains some tasks Task have a Task Execution Result Project Manager feedbacks Task Execution Result Project Manager read Project related information Figure 5, Associations of classes identified OOAD Homework (Spring 2006) 19
  • 21. System 1 1 Generate Generate 1 Generate Create 1 1 1 Administrator Generate * 1 1 * 1 Project List List of Functions Function Create 1 * Read Contains Separate 1 1 1 * Project Consist of * 1 1 1 1 Create 1 * * * Contains User List Project Manager 1 Manage 1 Task Task List Create 1 * 1 Consist of 1 * * 1 1 Contains Consist of 1 1 1 Consist of * Task Executing Project Member Result Have * 1 * 1 Feedback 1 1 Read Read Read Read Figure 6, Class model with associations OOAD Homework (Spring 2006) 20
  • 22. 2.3 Add Attributes Figure 7, Class model with associations and attributes OOAD Homework (Spring 2006) 21
  • 23. 3. CLASS DESIGN 3.1 Use-Case Realizations with GRASP Patterns 3.1.1 Choose the most significant use-case, identify system events, and draw a system sequence diagram for that use case. The work for this section is to choose the most significant use-case, identify system events, and draw a system sequence diagram for that use case. After review those use-cases identified currently, I identify the Project Management (ref. to section 1.5.6) should be the most significant use-case, due to the variety of the processes of this use-case is the most core different with other project management systems. The system events identified are listed in the following table. System event Contract # startProjectManagement CO1 pickProject CO2 specifyManagementType CO3 createChildProject CO4 CreateTask CO5 SaveAndClose CO6 OOAD Homework (Spring 2006) 22
  • 24. Figure 8 shows the system sequence diagram for the project management use- case Figure 8, The system sequence diagram for “Project Managment” use-case (UC-04) OOAD Homework (Spring 2006) 23
  • 25. 3.1.2 Write a contract for each system operation (system event). Contract CO1: startProjectManagement Operation: startProjectManagement(userID: string) Cross References: Use Cases: UC-04 Precondition A project manager already logins into this system, and invoke the “Project Management” function. Postconditions: System conducts a project list which includes all projects which managed by him/her. And the information for each project are ID and name for each project. Contract CO2: pickProject Operation: pickProject(projectID: string) Cross References: Use Cases: UC-04 Precondition The system had returns the project list Postconditions: System knows about which project had been selected by the project manager. Contract CO3: specifyManageType Operation: specifyManageType(type: string) Cross References: Use Cases: UC-04 Precondition The selected project had been opened by the system. Postconditions: The management type (either Split Project or Create Tasks) for the project selected by project manager had made, and known by the system. Contract CO4: createChildProject Operation: createChildProject(projectID: string, projectName: string, userID: string) Cross References: Use Cases: UC-04 Precondition The management type “Split Project” was specified for current project management process. Postconditions: A new child project (which identified by projected, named in projectName, and managed by userID) was created. OOAD Homework (Spring 2006) 24
  • 26. The new created child project had been associated to the project which current managed. Contract CO5: createTask Operation: createTask(taskName: string, startDate: date, finished- Date: date, userID: string) Cross References: Use Cases: UC-04 Precondition The management type “Create Tasks” was specified for current project management process. Postconditions: A new task was created and associated to the project which current managed. Contract CO6: saveAndClose Operation: saveAndClose Cross References: Use Cases: UC-04 Precondition The selected project had been opened by the system. Some child projects or tasks may also been created. Postconditions: Based on the management type which specified by project manager, either the newly created projects or tasks were stored in the system data store. The project management process was finished. 3.1.3 Draw a sequence diagram for each system event you identified, and label with the GRASP patterns to describe how you assign responsibilities. The following figures shows the sequence diagram for each system event. OOAD Homework (Spring 2006) 25
  • 27. Figure 9, The sequence diagram for “startProjectManagement” system event :SystemController :Librarian :StoreManager pickProject(projectID) 1 requestProjectInfo (projectID) 2 requestProjectInfo (projectID) Project Name 3 createProject(projectID, projectName) :Project Project Name Information Creator Controller Low Coupling High Cohesion Expert 3 1, 2, 3 3 3 Figure 10, The sequence diagram for “pickProject” system event Figure 11, The sequence diagram for “specifyManagementType” system event OOAD Homework (Spring 2006) 26
  • 28. Figure 12, The sequence diagram for “createChildProject” system event Figure 13, The sequence diagram for “CreateTask” system event OOAD Homework (Spring 2006) 27
  • 29. Figure 14, The sequence diagram for “SaveAndClose” system event OOAD Homework (Spring 2006) 28
  • 30. 3.2 Design Class Model Figure 14, Domain class diagram (for Project Management, #UC-04) OOAD Homework (Spring 2006) 29
  • 31. 5. IMPLEMENTATION CLASS MODEL 5.1 Draw an implementation class diagram for your system (including associations, attributes and methods) Splits Figure 15, Implementation class diagram (for Project Management, #UC-04) OOAD Homework (Spring 2006) 30
  • 32. 5.2 Show the difference between implementation class model and design class model Table 5.2.1, Comparison with design and implementation class Class Method Design Imp. SystemController startProjectManagement Yes Yes pickProject Yes Yes specifyManageType Yes Yes createChildProject Yes Yes createTask Yes Yes saveAndClose Yes Yes requestProjectListByManager No Yes Librarian requestProjectListByManager Yes Yes requestProjectInfo Yes Yes setManageType Yes Yes createChildProject Yes Yes createTask Yes Yes saveAndClose Yes Yes getProjectInfo No Yes Project createProject Yes (constructor) setManageType Yes Yes createChildProject Yes Yes createAChildProject Yes No createTask Yes Yes getProjectInfoforSave Yes No getProjectInfo Yes Yes close Yes Yes InitProjectInfo No Yes Task createATask Yes (constructor) getTaskInfo Yes Yes close Yes Yes StorageManager requestProjectListByManager Yes Yes requestProjectInfo Yes Yes saveProjectInfo Yes Yes StorageManagerXML StorageManagerXML No (constructor) requestProjectListByManager No Yes requestProjectInfo No Yes saveProjectInfo No Yes GetRootProjectID No Yes clearProjectInfoAllByProjectID No Yes insertProjectInfoIntoStorage No Yes ProjectList createProjectList Yes Yes Utility XMLInsertNode No Yes DateToString No Yes GlobalParameters (n/a) No Yes ProjectInfo (n/a) No Yes ProjectInList (n/a) No Yes OOAD Homework (Spring 2006) 31
  • 33. Table 5.2.2, Summary of implementation class/method changed Class # of added # of removed # of modified Class 4 0 3 Method (count with 15 2 0 private method) 5.3 Calculate Line of Code Table 5.3.1, Line of Code of Classes No Class Name # of Methods Line of Code in Class (without comment) 1 SystemController 7 39 2 Librarian 6 51 3 Project 9 125 4 Task 3 36 5 StorageManager 3 13 6 StorageManagerXML 7 191 7 ProjectList 1 19 8 Utility 2 26 9 GlobalParameters 0 5 10 ProjectInfo 0 10 11 ProjectInList 0 19 Summary 38 534 (Class(es) related to user interface prototyping was not counted) OOAD Homework (Spring 2006) 32
  • 34. 6. PROGRAMMING 6.1 Snapshots of system execution (optional) Figure 16, Snapshot – 1 of System Execution (for UC-04) OOAD Homework (Spring 2006) 33
  • 35. Figure 17, Snapshot – 2 of System Execution (for UC-04) 6.2 Source Code Listing 001: using System; 002: using System.Collections.Generic; 003: using System.Text; 004: 005: using System.Collections; 006: using System.IO; 007: using System.Xml; 008: 009: namespace HPMSLibs 010: { 011: //=== Global Parameters === 012: public static class GlobalParameters 013: { 014: //For XML storage 015: public static string AppPath = @"c:HPMSData"; 016: public static string XMLFile_Project = @"Projects.xml"; OOAD Homework (Spring 2006) 34
  • 36. 017: } 018: 019: //=== Support Classes & ENUM 020: public class ProjectInList 021: { 022: public string ProjectID = ""; 023: public string ProjectName = ""; 024: } 025: 026: public class ProjectInfo 027: { 028: public string ProjectID = ""; 029: public string ProjectName = ""; 030: public string ProjectManagerID = ""; 031: public string ParentProjectID = ""; 032: public ManageType MgmtType = ManageType.undefined; 033: public ArrayList Projects = new ArrayList(); 034: public ArrayList Tasks = new ArrayList(); 035: } 036: 037: public enum ManageType 038: { 039: undefined, splitProjects, splitTasks 040: } 041: 042: public static class Utility 043: { 044: public static XmlNode XMLInsertNode(XmlDocument xDoc, XmlNode xTarget, string sElementName, string sValue) 045: { 046: XmlNode xNode = xDoc.CreateElement(sElementName); 047: xNode.InnerText = sValue; 048: xTarget.AppendChild(xNode); 049: return xNode; 050: } 051: 052: public static string DateToString(DateTime dtDate) 053: { 054: string sDateString = ""; 055: if (dtDate.Year != 1) 056: { 057: string sYear = "0000" + dtDate.Year.ToString(); 058: sYear = sYear.Substring(sYear.Length - 4); 059: string sMonth = "00" + dtDate.Month.ToString(); 060: sMonth = sMonth.Substring(sMonth.Length - 2); 061: string sDay = "00" + dtDate.Day.ToString(); 062: sDay = sDay.Substring(sDay.Length - 2); 063: sDateString = sYear + "/" + sMonth + "/" + sDay; 064: } 065: return sDateString; 066: } 067: } 068: 069: //=== [Class] ProjectList 070: public class ProjectList 071: { 072: public ArrayList alProjects = new ArrayList(); 073: 074: public void createProjectList(string XMLProjects) 075: { 076: alProjects.Clear(); 077: 078: XmlDocument xProjects = new XmlDocument(); 079: xProjects.LoadXml(XMLProjects); 080: foreach(XmlNode xPrj in xProjects.DocumentElement.ChildNodes) 081: { 082: ProjectInList PrjInList = new ProjectInList(); 083: PrjInList.ProjectID = xPrj.SelectSingleNode("ID").InnerText; 084: PrjInList.ProjectName = OOAD Homework (Spring 2006) 35
  • 37. xPrj.SelectSingleNode("Name").InnerText; 085: alProjects.Add(PrjInList); 086: } 087: } 088: } 089: 090: //=== [Abstract Class] StorageManager 091: abstract public class StorageManager 092: { 093: protected ProjectList plPrjList; 094: 095: public StorageManager() 096: { 097: plPrjList = new ProjectList(); 098: } 099: 100: abstract public ArrayList requestProjectListByManager(string UserID); 101: abstract public ProjectInfo requestProjectInfo(string ProjectID); 102: abstract public bool saveProjectInfo(XmlDocument xProjectDoc); 103: } 104: 105: //=== [Class] StorageManagerXML 106: public class StorageManagerXML : StorageManager 107: { 108: private DirectoryInfo diStorage; 109: 110: public StorageManagerXML() 111: { 112: DirectoryInfo diStorage = new DirectoryInfo(GlobalParameters.AppPath); 113: } 114: 115: public override ArrayList requestProjectListByManager(string UserID) 116: { 117: XmlDocument xResults = new XmlDocument(); 118: xResults.LoadXml("<Projects />"); 119: 120: diStorage = new DirectoryInfo(GlobalParameters.AppPath); 121: XmlDocument xProjects = new XmlDocument(); 122: xProjects.Load(diStorage.FullName + @"" + GlobalParameters.XMLFile_Project); 123: XmlNodeList xProjectByManager = xProjects.DocumentElement.SelectNodes("//Project[@Manager="" + UserID + ""]"); 124: foreach (XmlNode xProject in xProjectByManager) 125: { 126: XmlNode xPrj = xResults.CreateElement("Project"); 127: 128: Utility.XMLInsertNode(xResults, xPrj, "ID", xProject.Attributes["ID"].Value); 129: Utility.XMLInsertNode(xResults, xPrj, "Name", xProject.Attributes["Name"].Value); 130: 131: xResults.DocumentElement.AppendChild(xPrj); 132: } 133: this.plPrjList.createProjectList(xResults.InnerXml); 134: return this.plPrjList.alProjects; 135: } 136: 137: public override ProjectInfo requestProjectInfo(string ProjectID) 138: { 139: ProjectInfo PrjInfo = new ProjectInfo(); 140: 141: diStorage = new DirectoryInfo(GlobalParameters.AppPath); 142: XmlDocument xProjects = new XmlDocument(); 143: xProjects.Load(diStorage.FullName + @"" + GlobalParameters.XMLFile_Project); 144: XmlNode xProject = xProjects.DocumentElement.SelectSingleNode("//Project[@ID="" + ProjectID + OOAD Homework (Spring 2006) 36
  • 38. ""]"); 145: 146: PrjInfo.ProjectID = xProject.Attributes["ID"].Value; 147: PrjInfo.ProjectName = xProject.Attributes["Name"].Value; 148: PrjInfo.ProjectManagerID = xProject.Attributes["Manager"].Value; 149: PrjInfo.ParentProjectID = xProject.Attributes["ParentProject"].Value; 150: string sMgmtType = xProject.Attributes["ManageType"].Value; 151: if (sMgmtType == "0") 152: { 153: PrjInfo.MgmtType = ManageType.undefined; 154: } 155: else 156: { 157: if (sMgmtType == "1") 158: { 159: PrjInfo.MgmtType = ManageType.splitProjects; 160: 161: //Process Child Projects 162: XmlNodeList xChildProjects = xProject.SelectNodes("ChildProjects/ChildProject"); 163: foreach (XmlNode xChildProject in xChildProjects) 164: { 165: string projectID = xChildProject.Attributes["ID"].Value; 166: Project ChildProject = new Project(this, "", "", "", ""); 167: ChildProject.InitProjectInfo(projectID); 168: PrjInfo.Projects.Add(ChildProject); 169: } 170: } 171: else 172: { 173: PrjInfo.MgmtType = ManageType.splitTasks; 174: 175: //Process Tasks 176: XmlNodeList xTasks = xProject.SelectNodes("Tasks/Task"); 177: foreach (XmlNode xTask in xTasks) 178: { 179: string sProjectID = ProjectID; 180: string sTaskID = xTask.Attributes["ID"].Value; 181: string sTaskName = xTask.Attributes["Name"].Value; 182: DateTime dtStartDate; 183: string sStartDate = xTask.Attributes["StartDate"].Value; 184: if (sStartDate == "") 185: dtStartDate = new DateTime(); 186: else 187: { 188: dtStartDate = new DateTime(int.Parse(sStartDate.Substring(0, 4)), int.Parse(sStartDate.Substring(5, 2)), int.Parse(sStartDate.Substring(8, 2))); 189: } 190: DateTime dtFinishDate; 191: string sFinishDate = xTask.Attributes["FinishDate"].Value; 192: if (sFinishDate == "") 193: dtFinishDate = new DateTime(); 194: else 195: { 196: dtFinishDate = new DateTime(int.Parse(sFinishDate.Substring(0, 4)), int.Parse(sFinishDate.Substring(5, 2)), int.Parse(sFinishDate.Substring(8, 2))); 197: } 198: string sProjectMemberID = xTask.Attributes["ProjectMemberID"].Value; 199: Task task = new Task(ProjectID, sTaskID, sTaskName, dtStartDate, dtFinishDate, sProjectMemberID); OOAD Homework (Spring 2006) 37
  • 39. 200: PrjInfo.Tasks.Add(task); 201: } 202: } 203: } 204: 205: return PrjInfo; 206: } 207: 208: public override bool saveProjectInfo(XmlDocument xProjectDoc) 209: { 210: bool bResult = true; 211: 212: diStorage = new DirectoryInfo(GlobalParameters.AppPath); 213: XmlDocument xProjects = new XmlDocument(); 214: xProjects.Load(diStorage.FullName + @"" + GlobalParameters.XMLFile_Project); 215: 216: this.clearProjectInfoAllByProjectID(xProjects, this.GetRootProjectID(xProjectDoc)); 217: this.insertProjectInfoIntoStorage(xProjects, xProjectDoc.DocumentElement); 218: 219: xProjects.Save(diStorage.FullName + @"" + GlobalParameters.XMLFile_Project); 220: 221: return bResult; 222: } 223: 224: private string GetRootProjectID(XmlDocument xProject) 225: { 226: return xProject.SelectSingleNode("Project").SelectSingleNode("ID").InnerText; 227: } 228: 229: private void clearProjectInfoAllByProjectID(XmlDocument xProjects, string ProjectID) 230: { 231: XmlNode xProject = xProjects.DocumentElement.SelectSingleNode("//Project[@ID="" + ProjectID + ""]"); 232: if (xProject.Attributes["ManageType"].Value == "1") 233: { 234: XmlNodeList xChildProjects = xProject.SelectNodes("ChildProjects/ChildProject"); 235: foreach (XmlNode xChildProject in xChildProjects) 236: { 237: this.clearProjectInfoAllByProjectID(xProjects, xChildProject.Attributes["ID"].Value); 238: } 239: } 240: xProjects.DocumentElement.RemoveChild(xProject); 241: } 242: 243: private void insertProjectInfoIntoStorage(XmlDocument xProjects, XmlElement xProject) 244: { 245: string ProjectID = xProject.SelectSingleNode("ID").InnerText; 246: string ProjectName = xProject.SelectSingleNode("Name").InnerText; 247: string Manager = xProject.SelectSingleNode("Manager").InnerText; 248: string ParentProject = xProject.SelectSingleNode("ParentProject").InnerText; 249: string ManageType = xProject.SelectSingleNode("ManageType").InnerText; 250: 251: XmlNode xProjectNode = Utility.XMLInsertNode(xProjects, (XmlNode)xProjects.DocumentElement, "Project", ""); 252: ((XmlElement)xProjectNode).SetAttribute("ID", ProjectID); 253: ((XmlElement)xProjectNode).SetAttribute("Name", ProjectName); OOAD Homework (Spring 2006) 38
  • 40. 254: ((XmlElement)xProjectNode).SetAttribute("Manager", Manager); 255: ((XmlElement)xProjectNode).SetAttribute("ParentProject", ParentProject); 256: ((XmlElement)xProjectNode).SetAttribute("ManageType", ManageType); 257: 258: if (ManageType == "1") 259: { 260: XmlNode xChildPrjs = Utility.XMLInsertNode(xProjects, xProjectNode, "ChildProjects", ""); 261: 262: XmlNodeList xChildProjects = xProject.SelectNodes("ChildProjects/ChildProject/Project"); 263: foreach (XmlNode xChildProject in xChildProjects) 264: { 265: this.insertProjectInfoIntoStorage(xProjects, (XmlElement)xChildProject); 266: 267: XmlNode xChildPrj = Utility.XMLInsertNode(xProjects, xChildPrjs, "ChildProject", ""); 268: ((XmlElement)xChildPrj).SetAttribute("ID", xChildProject.SelectSingleNode("ID").InnerText); 269: } 270: } 271: 272: if (ManageType == "2") 273: { 274: XmlNode xTasks = Utility.XMLInsertNode(xProjects, xProjectNode, "Tasks", ""); 275: 276: XmlNodeList xChildTasks = xProject.SelectNodes("Tasks/Task/Task"); 277: foreach (XmlNode xChildTask in xChildTasks) 278: { 279: //<Task ID="TSK001.001" Name="Envision" StartDate="" FinishDate="" ProjectMemberID=""></Task> 280: //<ID>TSK001.001</ID><Name>Envision</Name><StartDate></StartDate><FinishDate></F inishDate><ProjectMemberID></ProjectMemberID> 281: string TaskID = xChildTask.SelectSingleNode("ID").InnerText; 282: string TaskName = xChildTask.SelectSingleNode("Name").InnerText; 283: string StartDate = xChildTask.SelectSingleNode("StartDate").InnerText; 284: string FinishDate = xChildTask.SelectSingleNode("FinishDate").InnerText; 285: string ProjectMemberID = xChildTask.SelectSingleNode("ProjectMemberID").InnerText; 286: 287: XmlNode xTask = Utility.XMLInsertNode(xProjects, xTasks, "Task", ""); 288: ((XmlElement)xTask).SetAttribute("ID", TaskID); 289: ((XmlElement)xTask).SetAttribute("Name", TaskName); 290: ((XmlElement)xTask).SetAttribute("StartDate", StartDate); 291: ((XmlElement)xTask).SetAttribute("FinishDate", FinishDate); 292: ((XmlElement)xTask).SetAttribute("ProjectMemberID", ProjectMemberID); 293: } 294: } 295: } 296: } 297: 298: //=== [Class] Task 299: public class Task 300: { 301: private string projectID; 302: private string taskID; OOAD Homework (Spring 2006) 39
  • 41. 303: private string taskName; 304: private DateTime startDate; 305: private DateTime finishedDate; 306: private string projectMemberID; 307: 308: public Task(string ProjectID, string TaskID, string TaskName, DateTime StartDate, DateTime FinishedDate, string ProjectMemberID) 309: { 310: projectID = ProjectID; 311: taskID = TaskID; 312: taskName = TaskName; 313: startDate = StartDate; 314: finishedDate = FinishedDate; 315: projectMemberID = ProjectMemberID; 316: } 317: 318: public void Close() 319: { 320: // No implementation code for this member function currently. 321: } 322: 323: public XmlDocument getTaskInfo() 324: { 325: XmlDocument xTask = new XmlDocument(); 326: xTask.LoadXml("<Task />"); 327: Utility.XMLInsertNode(xTask, xTask.DocumentElement, "ID", taskID); 328: Utility.XMLInsertNode(xTask, xTask.DocumentElement, "Name", taskName); 329: Utility.XMLInsertNode(xTask, xTask.DocumentElement, "StartDate", Utility.DateToString(startDate)); 330: Utility.XMLInsertNode(xTask, xTask.DocumentElement, "FinishDate", Utility.DateToString(finishedDate)); 331: Utility.XMLInsertNode(xTask, xTask.DocumentElement, "ProjectMemberID", projectMemberID); 332: return xTask; 333: } 334: } 335: 336: //=== [Class] Project 337: public class Project 338: { 339: private StorageManager sm; 340: 341: private ManageType manageType; 342: private string projectID; 343: private string projectName; 344: private string projectManagerID; 345: private string parentProject; 346: private ArrayList ChildProjects = new ArrayList(); 347: private ArrayList Tasks = new ArrayList(); 348: 349: public Project(StorageManager SM, string ProjectID, string ProjectName, string ProjectManagerID, string ParentProject) 350: { 351: sm = SM; 352: projectID = ProjectID; 353: projectName = ProjectName; 354: projectManagerID = ProjectManagerID; 355: parentProject = ParentProject; 356: ChildProjects = new ArrayList(); 357: Tasks = new ArrayList(); 358: } 359: 360: public void InitProjectInfo(string ProjectID) 361: { 362: ProjectInfo PrjInfo = sm.requestProjectInfo(ProjectID); 363: projectID = PrjInfo.ProjectID; 364: projectName = PrjInfo.ProjectName; 365: projectManagerID = PrjInfo.ProjectManagerID; OOAD Homework (Spring 2006) 40
  • 42. 366: parentProject = PrjInfo.ParentProjectID; 367: manageType = PrjInfo.MgmtType; 368: if (manageType != ManageType.undefined) 369: { 370: if (PrjInfo.MgmtType == ManageType.splitProjects) 371: { 372: foreach (Project project in PrjInfo.Projects) 373: { 374: ChildProjects.Add(project); 375: } 376: } 377: else 378: { 379: foreach (Task task in PrjInfo.Tasks) 380: { 381: Tasks.Add(task); 382: } 383: } 384: } 385: } 386: 387: public void close() 388: { 389: // No implementation code for this member function currently. 390: } 391: 392: public void setManageType(ManageType MgmtType) 393: { 394: this.manageType = MgmtType; 395: } 396: 397: public XmlDocument getProjectInfo() 398: { 399: XmlDocument xProject = new XmlDocument(); 400: xProject.LoadXml("<Project />"); 401: Utility.XMLInsertNode(xProject, xProject.DocumentElement, "ID", projectID); 402: Utility.XMLInsertNode(xProject, xProject.DocumentElement, "Name", projectName); 403: Utility.XMLInsertNode(xProject, xProject.DocumentElement, "Manager", projectManagerID); 404: Utility.XMLInsertNode(xProject, xProject.DocumentElement, "ParentProject", parentProject); 405: switch (manageType) 406: { 407: case ManageType.splitProjects: 408: Utility.XMLInsertNode(xProject, xProject.DocumentElement, "ManageType", "1"); 409: XmlElement xChildProjects = xProject.CreateElement("ChildProjects"); 410: foreach (Project ChildProject in ChildProjects) 411: { 412: XmlElement xChildProject = xProject.CreateElement("ChildProject"); 413: XmlDocument xChildProjectDoc = ChildProject.getProjectInfo(); 414: xChildProject.InnerXml = xChildProjectDoc.OuterXml; 415: xChildProjects.AppendChild(xChildProject); 416: } 417: xProject.DocumentElement.AppendChild(xChildProjects); 418: break; 419: case ManageType.splitTasks: 420: Utility.XMLInsertNode(xProject, xProject.DocumentElement, "ManageType", "2"); 421: XmlElement xTasks = xProject.CreateElement("Tasks"); 422: foreach (Task task in Tasks) 423: { 424: XmlElement xTask = xProject.CreateElement("Task"); 425: XmlDocument xTaskDoc = task.getTaskInfo(); 426: xTask.InnerXml = xTaskDoc.OuterXml; OOAD Homework (Spring 2006) 41
  • 43. 427: xTasks.AppendChild(xTask); 428: } 429: xProject.DocumentElement.AppendChild(xTasks); 430: break; 431: default: 432: Utility.XMLInsertNode(xProject, xProject.DocumentElement, "ManageType", "0"); 433: break; 434: } 435: return xProject; 436: } 437: 438: public bool createChildProject(string ProjectID, string ProjectName, string UserID) 439: { 440: bool bResult = false; 441: if (this.manageType == ManageType.splitProjects) 442: { 443: Project project = new Project(this.sm, ProjectID, ProjectName, UserID, this.projectID); 444: this.ChildProjects.Add(project); 445: bResult = true; 446: } 447: return bResult; 448: } 449: 450: public bool CreateTask(string TaskID, string TaskName, DateTime StartDate, DateTime FinishedDate, string UserID) 451: { 452: bool bResult = false; 453: if (this.manageType == ManageType.splitTasks) 454: { 455: Task task = new Task(this.projectID, TaskID, TaskName, StartDate, FinishedDate, UserID); 456: this.Tasks.Add(task); 457: bResult = true; 458: } 459: return bResult; 460: } 461: } 462: 463: //=== [Class] Librarian 464: public class Librarian 465: { 466: StorageManager sm = new StorageManagerXML(); 467: private Project currentManagedProject; 468: 469: public ArrayList requestProjectListByManager(string UserID) 470: { 471: return sm.requestProjectListByManager(UserID); 472: } 473: 474: public void requestProjectInfo(string ProjectID) 475: { 476: if(currentManagedProject!=null) 477: currentManagedProject.close(); 478: 479: currentManagedProject = new Project(sm, "", "", "", ""); 480: currentManagedProject.InitProjectInfo(ProjectID); 481: } 482: 483: public void setManageType(ManageType MgmtType) 484: { 485: currentManagedProject.setManageType(MgmtType); 486: } 487: 488: public bool CreateProject(string ProjectID, string ProjectName, string UserID) 489: { 490: bool bResult = false; OOAD Homework (Spring 2006) 42
  • 44. 491: if (this.sm != null) 492: if (this.currentManagedProject != null) 493: bResult = this.currentManagedProject.createChildProject(ProjectID, ProjectName, UserID); 494: return bResult; 495: } 496: 497: public bool CreateTask(string TaskID, string TaskName, DateTime StartDate, DateTime FinishedDate, string UserID) 498: { 499: bool bResult = false; 500: if (this.sm != null) 501: if (this.currentManagedProject != null) 502: bResult = this.currentManagedProject.CreateTask(TaskID, TaskName, StartDate, FinishedDate, UserID); 503: return bResult; 504: } 505: 506: public bool SaveAndClose() 507: { 508: return this.sm.saveProjectInfo(this.currentManagedProject.getProjectInfo()); 509: } 510: 511: public XmlDocument getProjectInfo() 512: { 513: return this.currentManagedProject.getProjectInfo(); 514: } 515: } 516: 517: //=== [Class] SystemController 518: public class SystemController 519: { 520: private Librarian Lib = new Librarian(); 521: 522: public ArrayList requestProjectListByManager(string UserID) 523: { 524: return Lib.requestProjectListByManager(UserID); 525: } 526: 527: public XmlDocument startProjectManagement() 528: { 529: return this.Lib.getProjectInfo(); 530: } 531: 532: public void pickProject(string ProjectID) 533: { 534: Lib.requestProjectInfo(ProjectID); 535: } 536: 537: public void specifyManageType(ManageType MgmtType) 538: { 539: Lib.setManageType(MgmtType); 540: } 541: 542: public bool createChildProject(string ProjectID, string ProjectName, string UserID) 543: { 544: return this.Lib.CreateProject(ProjectID, ProjectName, UserID); 545: } 546: 547: public bool CreateTask(string TaskID, string TaskName, DateTime StartDate, DateTime FinishedDate, string UserID) 548: { 549: return this.Lib.CreateTask(TaskID, TaskName, StartDate, FinishedDate, UserID); 550: } 551: 552: public bool SaveAndClose() 553: { OOAD Homework (Spring 2006) 43
  • 45. 554: return this.Lib.SaveAndClose(); 555: } 556: } 557: } Figure 18, Source Code – HPMSLibs.cs OOAD Homework (Spring 2006) 44
  • 46. 7. UNIT TESTING 7.1 Snapshots of testing result (optional) Figure 18, Snapshot – Unit Test Result (for UC-04) 7.2 Unit Testing Code Listing 001: using System; 002: using System.Collections.Generic; 003: using System.Text; 004: 005: using NUnit.Framework; 006: using HPMSLibs; 007: using System.Xml; 008: using System.Collections; 009: 010: namespace HPMSLibs 011: { 012: [TestFixture] 013: public class HPMSLibs_UnitTest 014: { 015: private ProjectInfo tProjectInfo; OOAD Homework (Spring 2006) 45
  • 47. 016: private XmlDocument xProject; 017: private ProjectList tProjectList; 018: private StorageManagerXML tStorageManagerXML; 019: private ArrayList alProjects; 020: private Task tTask; 021: private Project tProject; 022: private Librarian tLibrarian; 023: private SystemController tSystemController; 024: 025: [SetUp] 026: protected void SetUp() 027: { 028: tProjectInfo = new ProjectInfo(); 029: xProject = new XmlDocument(); 030: tProjectList = new ProjectList(); 031: tStorageManagerXML = new StorageManagerXML(); 032: alProjects = new ArrayList(); 033: tLibrarian = new Librarian(); 034: tSystemController = new SystemController(); 035: } 036: 037: [Test] 038: public void Class_GlobalParameters() 039: { 040: Assert.AreEqual(@"c:HPMSData", GlobalParameters.AppPath); 041: Assert.AreEqual(@"Projects.xml", GlobalParameters.XMLFile_Project); 042: } 043: 044: [Test] 045: public void Class_ProjectInfo() 046: { 047: Assert.AreEqual(ManageType.undefined, tProjectInfo.MgmtType); 048: Assert.AreEqual(@"", tProjectInfo.ParentProjectID); 049: Assert.AreEqual(@"", tProjectInfo.ProjectID); 050: Assert.AreEqual(@"", tProjectInfo.ProjectManagerID); 051: Assert.AreEqual(@"", tProjectInfo.ProjectName); 052: Assert.AreEqual(0, tProjectInfo.Projects.Count); 053: Assert.AreEqual(0, tProjectInfo.Tasks.Count); 054: } 055: 056: [Test] 057: public void Class_Utility_XMLInsertNode() 058: { 059: xProject.LoadXml("<Projects />"); 060: XmlNode xNewNode1 = Utility.XMLInsertNode(xProject, xProject.DocumentElement, "Test1", "ABC"); 061: Assert.AreEqual("<Projects><Test1>ABC</Test1></Projects>", xProject.OuterXml); 062: Assert.AreEqual("<Test1>ABC</Test1>", xNewNode1.OuterXml); 063: XmlNode xNewNode2 = Utility.XMLInsertNode(xProject, xProject.DocumentElement, "Test2", ""); 064: Assert.AreEqual("<Test2></Test2>", xNewNode2.OuterXml); 065: } 066: 067: [Test] 068: public void Class_Utility_DateToString() 069: { 070: Assert.AreEqual("2000/01/01", Utility.DateToString(new DateTime(2000, 1, 1))); 071: Assert.AreEqual("1990/01/31", Utility.DateToString(new DateTime(1990, 1, 31))); 072: Assert.AreEqual("2005/02/28", Utility.DateToString(new DateTime(2005, 2, 28))); 073: Assert.AreEqual("1990/07/31", Utility.DateToString(new DateTime(1990, 7, 31))); 074: Assert.AreEqual("1990/08/31", Utility.DateToString(new DateTime(1990, 8, 31))); 075: Assert.AreEqual("2004/02/29", Utility.DateToString(new DateTime(2004, 2, 29))); OOAD Homework (Spring 2006) 46
  • 48. 076: } 077: 078: [Test] 079: public void Class_ProjectList() 080: { 081: Assert.AreEqual(0, tProjectList.alProjects.Count); 082: tProjectList.createProjectList("<Projects></Projects>"); 083: Assert.AreEqual(0, tProjectList.alProjects.Count); 084: tProjectList.createProjectList("<Projects><Project><ID>PRJ001</ID><Name>Project1 </Name></Project></Projects>"); 085: Assert.AreEqual(1, tProjectList.alProjects.Count); 086: Assert.AreEqual("PRJ001", ((ProjectInList)tProjectList.alProjects[0]).ProjectID); 087: Assert.AreEqual("Project1", ((ProjectInList)tProjectList.alProjects[0]).ProjectName); 088: tProjectList.createProjectList("<Projects><Project><ID>PRJ001</ID><Name>Project1 </Name></Project><Project><ID>PRJ002</ID><Name>Project2</Name></Project></Projec ts>"); 089: Assert.AreEqual(2, tProjectList.alProjects.Count); 090: Assert.AreEqual("PRJ001", ((ProjectInList)tProjectList.alProjects[0]).ProjectID); 091: Assert.AreEqual("Project1", ((ProjectInList)tProjectList.alProjects[0]).ProjectName); 092: Assert.AreEqual("PRJ002", ((ProjectInList)tProjectList.alProjects[1]).ProjectID); 093: Assert.AreEqual("Project2", ((ProjectInList)tProjectList.alProjects[1]).ProjectName); 094: tProjectList.createProjectList("<Projects><Project><ID>PRJ001</ID><Name>Project1 </Name></Project><Project><ID>PRJ002</ID><Name>Project2</Name></Project><Project ><ID></ID><Name></Name></Project></Projects>"); 095: Assert.AreEqual(3, tProjectList.alProjects.Count); 096: Assert.AreEqual("PRJ001", ((ProjectInList)tProjectList.alProjects[0]).ProjectID); 097: Assert.AreEqual("Project1", ((ProjectInList)tProjectList.alProjects[0]).ProjectName); 098: Assert.AreEqual("PRJ002", ((ProjectInList)tProjectList.alProjects[1]).ProjectID); 099: Assert.AreEqual("Project2", ((ProjectInList)tProjectList.alProjects[1]).ProjectName); 100: Assert.AreEqual("", ((ProjectInList)tProjectList.alProjects[2]).ProjectID); 101: Assert.AreEqual("", ((ProjectInList)tProjectList.alProjects[2]).ProjectName); 102: } 103: 104: [Test] 105: public void Class_StorageManagerXML() 106: { 107: alProjects = tStorageManagerXML.requestProjectListByManager(""); 108: Assert.AreEqual(0, alProjects.Count); 109: alProjects = tStorageManagerXML.requestProjectListByManager("94419001"); 110: Assert.AreEqual(0, alProjects.Count); 111: alProjects = tStorageManagerXML.requestProjectListByManager("94419012"); 112: Assert.AreEqual(2, alProjects.Count); 113: Assert.AreEqual("PRJ001", ((ProjectInList)alProjects[0]).ProjectID); 114: Assert.AreEqual("Marketing Information Warehouse", ((ProjectInList)alProjects[0]).ProjectName); 115: Assert.AreEqual("PRJ002", ((ProjectInList)alProjects[1]).ProjectID); 116: Assert.AreEqual("Best Practice", ((ProjectInList)alProjects[1]).ProjectName); 117: tProjectInfo = tStorageManagerXML.requestProjectInfo("PRJ001"); 118: Assert.AreEqual("PRJ001", tProjectInfo.ProjectID); OOAD Homework (Spring 2006) 47
  • 49. 119: Assert.AreEqual("Marketing Information Warehouse", tProjectInfo.ProjectName); 120: Assert.AreEqual("PRJ002", tProjectInfo.ParentProjectID); 121: Assert.AreEqual("94419012", tProjectInfo.ProjectManagerID); 122: Assert.AreEqual(ManageType.splitTasks, tProjectInfo.MgmtType); 123: Assert.AreEqual(0, tProjectInfo.Projects.Count); 124: Assert.AreEqual(5, tProjectInfo.Tasks.Count); 125: Assert.AreEqual("<Task><ID>TSK001.001</ID><Name>Envision</Name><StartDate></Star tDate><FinishDate></FinishDate><ProjectMemberID></ProjectMemberID></Task>", ((Task)tProjectInfo.Tasks[0]).getTaskInfo().OuterXml); 126: Assert.AreEqual("<Task><ID>TSK001.002</ID><Name>Planning</Name><StartDate></Star tDate><FinishDate></FinishDate><ProjectMemberID></ProjectMemberID></Task>", ((Task)tProjectInfo.Tasks[1]).getTaskInfo().OuterXml); 127: Assert.AreEqual("<Task><ID>TSK001.003</ID><Name>Developing</Name><StartDate></St artDate><FinishDate></FinishDate><ProjectMemberID></ProjectMemberID></Task>", ((Task)tProjectInfo.Tasks[2]).getTaskInfo().OuterXml); 128: Assert.AreEqual("<Task><ID>TSK001.004</ID><Name>Deployment</Name><StartDate></St artDate><FinishDate></FinishDate><ProjectMemberID></ProjectMemberID></Task>", ((Task)tProjectInfo.Tasks[3]).getTaskInfo().OuterXml); 129: Assert.AreEqual("<Task><ID>TSK001.005</ID><Name>Stablizing</Name><StartDate></St artDate><FinishDate></FinishDate><ProjectMemberID></ProjectMemberID></Task>", ((Task)tProjectInfo.Tasks[4]).getTaskInfo().OuterXml); 130: tProjectInfo = tStorageManagerXML.requestProjectInfo("PRJ002"); 131: Assert.AreEqual("PRJ002", tProjectInfo.ProjectID); 132: Assert.AreEqual("Best Practice", tProjectInfo.ProjectName); 133: Assert.AreEqual("", tProjectInfo.ParentProjectID); 134: Assert.AreEqual("94419012", tProjectInfo.ProjectManagerID); 135: Assert.AreEqual(ManageType.splitProjects, tProjectInfo.MgmtType); 136: Assert.AreEqual(1, tProjectInfo.Projects.Count); 137: Assert.AreEqual("<Project><ID>PRJ001</ID><Name>Marketing Information Warehouse</Name><Manager>94419012</Manager><ParentProject>PRJ002</ParentProject> <ManageType>2</ManageType>" 138: + "<Tasks>" 139: + "<Task><Task><ID>TSK001.001</ID><Name>Envision</Name><StartDate></StartDate><Fin ishDate></FinishDate><ProjectMemberID></ProjectMemberID></Task></Task>" 140: + "<Task><Task><ID>TSK001.002</ID><Name>Planning</Name><StartDate></StartDate><Fin ishDate></FinishDate><ProjectMemberID></ProjectMemberID></Task></Task>" 141: + "<Task><Task><ID>TSK001.003</ID><Name>Developing</Name><StartDate></StartDate><F inishDate></FinishDate><ProjectMemberID></ProjectMemberID></Task></Task>" 142: + "<Task><Task><ID>TSK001.004</ID><Name>Deployment</Name><StartDate></StartDate><F inishDate></FinishDate><ProjectMemberID></ProjectMemberID></Task></Task>" 143: + "<Task><Task><ID>TSK001.005</ID><Name>Stablizing</Name><StartDate></StartDate><F inishDate></FinishDate><ProjectMemberID></ProjectMemberID></Task></Task>" 144: + "</Tasks>" 145: + "</Project>", ((Project)tProjectInfo.Projects[0]).getProjectInfo().OuterXml); 146: Assert.AreEqual(0, tProjectInfo.Tasks.Count); 147: } 148: 149: [Test] 150: public void Class_Task() 151: { 152: tTask = new Task("", "", "", new DateTime(2006, 3, 1), new DateTime(2006, 3, 31), ""); 153: Assert.AreEqual("<Task><ID></ID><Name></Name><StartDate>2006/03/01</StartDate><F inishDate>2006/03/31</FinishDate><ProjectMemberID></ProjectMemberID></Task>", tTask.getTaskInfo().OuterXml); OOAD Homework (Spring 2006) 48
  • 50. 154: tTask.Close(); 155: tTask = new Task("", "", "", new DateTime(2006, 3, 1), new DateTime(2006, 3, 31), ""); 156: tTask = new Task("PRJ001", "TASK001.001", "UnitTest", new DateTime(2006, 3, 1), new DateTime(2006, 3, 31), "94419012"); 157: Assert.AreEqual("<Task><ID>TASK001.001</ID><Name>UnitTest</Name><StartDate>2006/ 03/01</StartDate><FinishDate>2006/03/31</FinishDate><ProjectMemberID>94419012</P rojectMemberID></Task>", tTask.getTaskInfo().OuterXml); 158: } 159: 160: [Test] 161: public void Class_Project() 162: { 163: StorageManager sm = new StorageManagerXML(); 164: tProject = new Project(sm, "", "", "", ""); 165: tProject.InitProjectInfo("PRJ003"); 166: Assert.AreEqual("<Project><ID>PRJ003</ID><Name>Procurement Information Warehouse</Name><Manager>94419013</Manager><ParentProject></ParentProject><Manag eType>2</ManageType><Tasks /></Project>", tProject.getProjectInfo().OuterXml); 167: tProject = new Project(sm, "", "", "", ""); 168: Assert.AreEqual("<Project><ID></ID><Name></Name><Manager></Manager><ParentProjec t></ParentProject><ManageType>0</ManageType></Project>", tProject.getProjectInfo().OuterXml); 169: tProject.close(); 170: Assert.AreEqual("<Project><ID></ID><Name></Name><Manager></Manager><ParentProjec t></ParentProject><ManageType>0</ManageType></Project>", tProject.getProjectInfo().OuterXml); 171: tProject = new Project(sm, "PRJ001", "Project1", "94419012", "PRJ002"); 172: Assert.AreEqual("<Project><ID>PRJ001</ID><Name>Project1</Name><Manager>94419012< /Manager><ParentProject>PRJ002</ParentProject><ManageType>0</ManageType></Projec t>", tProject.getProjectInfo().OuterXml); 173: tProject.close(); 174: Assert.AreEqual("<Project><ID>PRJ001</ID><Name>Project1</Name><Manager>94419012< /Manager><ParentProject>PRJ002</ParentProject><ManageType>0</ManageType></Projec t>", tProject.getProjectInfo().OuterXml); 175: Assert.AreEqual(false, tProject.createChildProject("PRJ003", "Project3", "94419013")); 176: Assert.AreEqual(false, tProject.CreateTask("TSK001.001", "Task1", new DateTime(2005, 3, 1), new DateTime(2005, 3, 31), "94419013")); 177: tProject.setManageType(ManageType.undefined); 178: Assert.AreEqual(false, tProject.createChildProject("PRJ003", "Project3", "94419013")); 179: Assert.AreEqual(false, tProject.CreateTask("TSK001.001", "Task1", new DateTime(2005, 3, 1), new DateTime(2005, 3, 31), "94419013")); 180: tProject.setManageType(ManageType.splitProjects); 181: Assert.AreEqual(true, tProject.createChildProject("PRJ003", "Project3", "94419013")); 182: Assert.AreEqual(false, tProject.CreateTask("TSK001.001", "Task1", new DateTime(2005, 3, 1), new DateTime(2005, 3, 31), "94419013")); 183: tProject.setManageType(ManageType.splitTasks); 184: Assert.AreEqual(false, tProject.createChildProject("PRJ003", "Project3", "94419013")); 185: Assert.AreEqual(true, tProject.CreateTask("TSK001.001", "Task1", new DateTime(2005, 3, 1), new DateTime(2005, 3, 31), "94419013")); 186: } 187: 188: [Test] 189: public void Class_Librarian() 190: { 191: alProjects = tLibrarian.requestProjectListByManager(""); 192: Assert.AreEqual(0, alProjects.Count); 193: alProjects = tLibrarian.requestProjectListByManager("94419001"); OOAD Homework (Spring 2006) 49
  • 51. 194: Assert.AreEqual(0, alProjects.Count); 195: alProjects = tLibrarian.requestProjectListByManager("94419012"); 196: Assert.AreEqual(2, alProjects.Count); 197: Assert.AreEqual("PRJ001", ((ProjectInList)alProjects[0]).ProjectID); 198: Assert.AreEqual("Marketing Information Warehouse", ((ProjectInList)alProjects[0]).ProjectName); 199: Assert.AreEqual("PRJ002", ((ProjectInList)alProjects[1]).ProjectID); 200: Assert.AreEqual("Best Practice", ((ProjectInList)alProjects[1]).ProjectName); 201: tLibrarian.requestProjectInfo("PRJ003"); 202: tLibrarian.setManageType(ManageType.undefined); 203: Assert.AreEqual(false, tLibrarian.CreateProject("PRJ003", "Project3", "94419013")); 204: Assert.AreEqual(false, tLibrarian.CreateTask("TSK001.001", "Task1", new DateTime(2005, 3, 1), new DateTime(2005, 3, 31), "94419013")); 205: tLibrarian.setManageType(ManageType.splitProjects); 206: Assert.AreEqual(true, tLibrarian.CreateProject("PRJ003", "Project3", "94419013")); 207: Assert.AreEqual(false, tLibrarian.CreateTask("TSK001.001", "Task1", new DateTime(2005, 3, 1), new DateTime(2005, 3, 31), "94419013")); 208: tLibrarian.setManageType(ManageType.splitTasks); 209: Assert.AreEqual(false, tLibrarian.CreateProject("PRJ003", "Project3", "94419013")); 210: Assert.AreEqual(true, tLibrarian.CreateTask("TSK001.001", "Task1", new DateTime(2005, 3, 1), new DateTime(2005, 3, 31), "94419013")); 211: } 212: 213: [Test] 214: public void Class_SystemController() 215: { 216: alProjects = tSystemController.requestProjectListByManager(""); 217: Assert.AreEqual(0, alProjects.Count); 218: alProjects = tSystemController.requestProjectListByManager("94419001"); 219: Assert.AreEqual(0, alProjects.Count); 220: alProjects = tSystemController.requestProjectListByManager("94419012"); 221: Assert.AreEqual(2, alProjects.Count); 222: Assert.AreEqual("PRJ001", ((ProjectInList)alProjects[0]).ProjectID); 223: Assert.AreEqual("Marketing Information Warehouse", ((ProjectInList)alProjects[0]).ProjectName); 224: Assert.AreEqual("PRJ002", ((ProjectInList)alProjects[1]).ProjectID); 225: Assert.AreEqual("Best Practice", ((ProjectInList)alProjects[1]).ProjectName); 226: tSystemController.pickProject("PRJ003"); 227: tSystemController.specifyManageType(ManageType.undefined); 228: Assert.AreEqual(false, tSystemController.createChildProject("PRJ003", "Project3", "94419013")); 229: Assert.AreEqual(false, tSystemController.CreateTask("TSK001.001", "Task1", new DateTime(2005, 3, 1), new DateTime(2005, 3, 31), "94419013")); 230: tSystemController.specifyManageType(ManageType.splitProjects); 231: Assert.AreEqual(true, tSystemController.createChildProject("PRJ003", "Project3", "94419013")); 232: Assert.AreEqual(false, tSystemController.CreateTask("TSK001.001", "Task1", new DateTime(2005, 3, 1), new DateTime(2005, 3, 31), "94419013")); 233: tSystemController.specifyManageType(ManageType.splitTasks); 234: Assert.AreEqual(false, tSystemController.createChildProject("PRJ003", "Project3", "94419013")); 235: Assert.AreEqual(true, tSystemController.CreateTask("TSK001.001", "Task1", new DateTime(2005, 3, 1), new DateTime(2005, 3, 31), "94419013")); 236: } 237: } OOAD Homework (Spring 2006) 50
  • 52. 238: } Figure 19, Source Code – HPMSLibs_UT.cs OOAD Homework (Spring 2006) 51

×