Asm2 1ST Apdp Truongnn BH00704
Asm2 1ST Apdp Truongnn BH00704
Asm2 1ST Apdp Truongnn BH00704
Unit number and title Unit 20: Applied Programming and Design Principles
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that making a
false declaration is a form of malpractice.
Grading grid
P5 M3 P6 P7 M4 D2
OBSERVATION RECORD
Student
Date:
signature:
Assessor
Date:
signature:
Assessor
name:
Student 2 Cù Đăng Trường Giang
Student
Date:
signature:
Assessor
Date:
signature:
Assessor
name:
Student 3 Nguyễn Hữu Lâm
homeadmincontroller which has the following functions: -Add, edit, delete member information
Student
Date:
signature:
Assessor
Date:
signature:
Assessor
name:
Student 4 Nguyễn Nam Trường
Student
Date:
signature:
Assessor
Date:
signature:
Assessor
name:
r Summative Feedback: r Resubmission Feedback:
In the ever-evolving landscape of higher education, universities are continuously seeking ways to enhancetheir operational efficiency and
adapt to modern technological standards. Recognizing the pivotal role of a well-structured Student Information Management System (SIMS)
in fostering effective academic administration, our university is embarking on a journey to modernize and elevate its existing SIMS. The aim
is to not only streamline administrative processes but also to embrace contemporary software engineering principles for improved
maintainability and scalability.
To spearhead this transformative initiative, our university has assembled a dynamic team of skilled individuals, and we are honored to be
entrusted with the responsibility of implementing the next- generation SIMS. This project will be characterized by a commitment to Object-
Oriented Principles, adherence to SOLID principles, dedication to clean coding practices, and the incorporation of well- established design
patterns.
Through this undertaking, our goal is to contribute to the academic success of our university and set a benchmark for modern, efficient, and
user-centric student information systems. The journey begins with a robust analysis of user requirements and a thoughtful system design, setting
the foundation for a transformative project that will shape the future of our academic administration.
B. Content
I. Activity 1. Examine and discussion different test methods of implementing automatic testing can be done for the SIMS application
1. What is Unit Test?
As the name implies, unit testing entails testing each 'unit' or 'individual component' of a software application. It is the first and most
common phase in software testing. Unit testing is performed by developers during the application's development phase since it demands
in-depth understanding of the internal architecture and programming. These tests can be automated and repeated periodically as needed.
It is done to ensure that the code is valid and follows logic. It enables developers to uncover issuesin the early stages of constructing the
program, enhancing confidence in the code (SearchSoftwareQuality.(n.d.).
• [Fact] attribute indicates that this method is a test case that should be executed by the xUnit testrunner.
• “StringCalculator” Initialization: An instance of “StringCalculator” is created, representing the classunder test.
• MAXIMUM_RESULT Constant: A string constant is defined with the value "1001", likelyrepresenting the input that will cause an
overflow condition.
• Action Definition: An action is defined to execute the Add method of the “StringCalculator”
▪ instance, passing in MAXIMUM_RESULT as the argument.
• Assertion: The test asserts that invoking the action should throw an “OverflowException,” which isthe expected behavior when the
result exceeds a certain threshold.
This test ensures that the Add method of the “StringCalculator” class correctly throws an “OverflowException” when the result
exceeds a certain threshold, as specified by the test case.
1. Integration Testing
Integration Testing is a type of testing in which software modules are logically integrated and tested in groups.
A typical software project consists of many modules, coded by programmers. Integration testing is testing the compatibility between those
modules.( SearchSoftwareQuality. (n.d.).
Therefore, integration testing is also known as I&T (Integration and Testing), String Testing and sometimes Thread Testing.
Figure 2: Integration Testing
Although each module has been Unit Tested, errors still exist for a number of reasons such as:
• Because each module is designed by an independent developer with different knowledge and programming logic, errors may arise when
integrating modules together.
• Customers will change design requirements during the module development process (adding requirements, updating requirements when
found unreasonable...) and these new requirements may not be subject to Unit Testing or integration. error.
• The interfaces of software modules with the database may not be compatible.
• When integrating modules into the system, they may not be compatible with the general configuration of the system.
• Incomplete handling of exceptions can cause errors.
Suppose you work for an IT organization that has been asked to develop an online shopping website for Camp World, a company that sells
camping equipment. Once requirements gathering, analysis and design were complete, a developer was assigned to develop each module below.
Once each module is assigned to a developer, the developer begins coding functionality on their individual machines. They deployed the
respective modules on their machines to see what worked and what didn't, when they started module development. After they completed
development, the developers tested their individual functions as part of their unit testing and found a number of defects. They have corrected
these defects. At this point, they feel their modules are complete. Integration testing should be performed to confirm that all modules work
together. When they deployed all their code in a common machine, they found that the application did not work as expected because the
individual modules did not work well together. There were some errors like - after logging in, the user's cart did not show the items they had
previously added, the invoice amount did not include shipping costs, etc.
In this way, Integration Testing helps us identify and fix problems and ensure that the entire application works as expected. (Ngan, 2019)
Each Module is designed by programmers who have the ability to program logic thanks to their understanding and differences from other
programmers. Performing integration testing will ensure certain integrity of the software.
Even at the time you develop modules, they can still change within the customer's own spec and these changes often cannot be tested in the
previous unit testing stages.
The interfaces as well as the database of the modules have been determined to be incomplete if combined together.
If system integration of modules is performed, they are often not compatible with the general configuration of the system.
3. End-to-end Testing
In the long term, End-to-End (E2E) testing refers to a comprehensive software testing approach aimed at evaluating the entire system's
functionality, behavior, and performance from the user's perspective. It involves testing the application's various components, modules,
and subsystems as an integrated whole to ensure that they function seamlessly together and meet the specified requirements.
E2E testing simulates real-world user scenarios, interactions, and workflows, typically spanning multiple layers of the application stack,
including the user interface, business logic, data persistence, and external integrations. Unlike unit testing or integration testing, which
focus on individual units or component interactions, E2E testing evaluates the application's end-to-end flow, covering all the steps a user
might take to accomplish a task or achieve a goal within the system. (SearchSoftwareQuality. (n.d.).
Built on the principles of "design by contract," xUnit focuses on using assertions to check the results of code snippets, determining whether they
function as expected. It supports programming styles such as Test-Driven Development (TDD) and Behavior-Driven Development (BDD), helping
to create quality, maintainable source code. (Stack Overflow. (n.d.)
Facts:
• Fact is an attribute used to mark a method as a test method that represents a single, atomic test case.
• Test methods marked with Fact do not take any input parameters and are intended to be used for scenarios where the test case does
not vary based on input data.
• Each method marked with Fact represents a distinct test case and is executed independently.
• Fact is suitable for scenarios where the test case has a fixed input and output, and the test method needs to be executed exactly once
during the test run.
For example,
Assertions:
Assertions are statements in code that verify whether an expected condition or result is true during runtime. In the context of testing, assertions
are used to validate the behavior and outcomes of the code being tested. If an assertion fails during execution, it indicates that the tested
condition or result does not meet the expected criteria, signaling a potential issue or defect in the code. (Literary Devices. (2015)
Assertions typically consist of a condition to be tested and an accompanying message or description to provide context and clarity about the
expectation. When the condition evaluates to false, the assertion fails, and an error or failure message is generated, indicating that the test case
did not pass as expected.
• We create a “Student” instance and add two grades (3.5 and 4.0) to it.
• We assert that the calculated GPA matches the expected value (3.75).
Student_GradeOutOfRange_ThrowsException:
II. Activity 2 Build a data processing application with automating testing based on a developed design
1. Student Information Management System (SIMS)
Purpose of SIMS
The Student Information Management System (SIMS) serves as a comprehensive tool for educational institutions to streamline their
administrative tasks, enhance communication channels, and effectively manage student data. At its core, SIMS is designed to simplify the
complexities associated with managing student information, thereby facilitating smoother operations within educational settings.
The primary purpose of SIMS is to centralize and organize various aspects of student data management. It allows schools and educational
institutions to efficiently collect, store, update, and retrieve student information, ranging from basic personal details to academic records,
attendance records, disciplinary actions, and more. By providing a centralized database for student information, SIMS enables administrators
and educators to access accurate and up-to-date information whenever needed, thereby reducing the time and effort required for administrative
tasks.
Login Function
In a Student Information Management System (SIMS), the login function plays a crucial role in verifying the identity of users and granting
access to the system's features and services. When users access the SIMS application, they encounter the login screen where they need to
provide valid login information, including their email address and previously registered password.
• Read the list of users from the JSON file: First, the function reads the existing list of users from the JSON file named "users.json". This
list contains information about all users in the system, including both students and teachers.
• Generate an ID for the new user: After reading the list of users, the system determines a new ID for the user about to be added. The
approach here is to find the largest ID in the current list and increment it by 1 to ensure the uniqueness of the ID for the new user.
• Assign ID and default role to the new user: After determining the new ID, the system assigns this ID to the new user being added. The
default role for the new user may be a student.
• Add the new user to the list: The new user is then added to the current list of users.
• Update the list of users in the JSON file: After adding the new user to the list, the system updates the JSON file "users.json" with this
new list of users.
As a student, you have the privilege to access and manage your enrolled courses, allowing you to view the courses you are currently
registered for and select additional courses to enroll in based on your academic interests and requirements. Additionally, you have the
opportunity to access your personalized timetable, providing you with a comprehensive schedule of your classes and academic
commitments. This functionality empowers you to effectively plan and organize your academic pursuits, ensuring you stay on track with
your educational goals.
Figure 17:Student Course
While there isn't a universally standardized SIMS, it's typically a software application used in schools to manage student data, attendance, grades,
and other administrative tasks. The specific functionalities and structure of your SIMS will depend on the vendor or custom development.
xUnit Framework:
A popular, free, and open-source testing framework for .NET development. It provides a clean syntax for writing unit tests, assertions for
verifying expected behavior, and features like parameterized tests and mocking for efficient testing. (Stack Overflow. (n.d.).
• This test checks what happens when the Index method of the HomeAdminController is called with specific arguments ("TestUser",
"Admin").
• It assumes the Index method is responsible for displaying a list of users.
• The assertions verify the following:
• The returned result is a ViewResult. This indicates the controller is returning a view (a webpage template) to be displayed.
• The model property of the ViewResult is assignable to a List<User>. This means the view is expecting a list of user objects as its data.
• The model list is not null, ensuring data is passed to the view.
Test 2: Edit_ReturnsNotFound_WhenUserNotFound
• This test checks what happens when the Edit method of the HomeAdminController is called with an invalid user ID (999 in this case).
• It assumes the Edit method is responsible for editing a specific user.
• The assertion verifies that the returned result is a NotFoundResult. This indicates the controller could not find the requested user with
the provided ID.
Test 3: NewStudent_ReturnsRedirectToActionResult_WhenModelStateIsValid
• This test checks what happens when the NewStudent method of the HomeAdminController is called with a new user object with specific
properties (Name: "Test User", Role: "Student").
• It assumes the NewStudent method is responsible for creating a new student user.
• The assertions verify the following:
• The returned result is a RedirectToActionResult. This indicates the controller is redirecting to another action after successful user
creation.
• The redirect action name is "Index", suggesting it redirects back to the user list view.
This test is likely verifying the behavior of the Detail method within the StudentController.
Arrange:
Act:
• The Detail method of the controller is called with the existingStudentId (1). This simulates requesting student details for ID 1.
• The result is stored in a variable named result.
Assert:
• The first assertion (Assert.IsType<ViewResult>(result)) checks if the result is of type ViewResult. This verifies the controller returns a view
(a webpage template) to display details.
• The second assertion (Assert.IsAssignableFrom<Student>(viewResult.ViewData.Model)) uses a more relaxed matching approach. It
checks if the model property of the ViewResult can be assigned to a Student object. This ensures the view expects a student object as its
data.
• The third assertion (Assert.NotNull(model)) confirms that the model property of the ViewResult is not null. This guarantees some student
data is passed to the view.
c) Teacher Function Test
Test 1: Edit_ReturnsNotFound_WhenUserNotFound
This test is similar to the previous ones we saw. It checks the behavior when the Edit method receives an invalid user ID:
Arranges:
Acts:
Asserts:
• Verifies the returned result is a NotFoundResult. This confirms the controller couldn't find a teacher with the provided ID.
Test 2: Edit_UpdatesUserCoreAndStatus_WhenUserExists
Arranges:
Acts:
• Calls the Edit method of the controller with the existingUser object.
Asserts:
• Verifies the returned result is a RedirectToActionResult. This indicates successful editing and redirection potentially back to a teacher list
view
C. Conclution
In conclusion, our university's commitment to enhancing operational efficiency and embracing modern technological standards through the
modernization of our Student Information Management System (SIMS) reflects our dedication to fostering academic excellence. By assembling
a dynamic team and adhering to Object-Oriented Principles, SOLID principles, and clean coding practices, we are poised to implement a next-
generation SIMS that not only streamlines administrative processes but also sets a benchmark for user-centric student information systems.
Through rigorous analysis of user requirements and meticulous system design, we lay the groundwork for a transformative project that will
shape the future of our academic administration. As we embark on this journey, we are driven by the vision of contributing to the academic
success of our university and creating a model for modern, efficient, and adaptable student information systems. Together, we stand ready to
embrace the challenges and opportunities that lie ahead, confident in our ability to pioneer positive change in higher education.
D. Reference
SearchSoftwareQuality. (n.d.). What is Automated Testing and How Does it Work? [online] Available at:
https://www.techtarget.com/searchsoftwarequality/definition/automated-software-testing [Accessed16 Mar. 2022].
Stack Overflow. (n.d.). What’s an xUnit runsettings equivalent? [online] Available at: https://stackoverflow.com/questions/38458979/whats-an-
xunit-runsettings-equivalent [Accessed 23Mar. 2024].