-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Added UnitTest for Charity class with JavaDoc
- Loading branch information
AdrianBalunan
committed
Mar 3, 2026
1 parent
ab584ac
commit 7e62703
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/models/CharityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,68 @@ | ||
| package ntnu.systemutvikling.team6.models; | ||
|
|
||
| import ntnu.sytemutvikling.team6.models.Charity; | ||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| /** | ||
| * UnitTesting for Charity. | ||
| * | ||
| * @author Adrian Balunan | ||
| */ | ||
| public class CharityTest { | ||
| private Charity charity; | ||
|
|
||
| @BeforeEach | ||
| public void setup(){ | ||
| charity = new Charity("Charity1", "Something Somewhere Somehow", "Cancer"); | ||
| } | ||
|
|
||
| /** | ||
| * Getters should work: | ||
| */ | ||
| @Test | ||
| public void gettingIdShouldWork(){ | ||
| assertInstanceOf(UUID.class, charity.getId()); | ||
| } | ||
| @Test | ||
| public void gettingCategoryShouldWork(){ | ||
| assertEquals("Cancer", charity.getCategory()); | ||
| } | ||
| @Test | ||
| public void gettingNameShouldWork(){ | ||
| assertEquals( "Charity1",charity.getName()); | ||
| } | ||
| @Test | ||
| public void gettingDescriptionShouldWork(){ | ||
| assertEquals("Something Somewhere Somehow",charity.getDescription()); | ||
| } | ||
|
|
||
| /** | ||
| * Getter and setter for IsVerified should be able to switch between true and false | ||
| */ | ||
| @Test | ||
| public void isVerifiedReturnsCorrectly(){ | ||
| assertFalse(charity.isVerified()); | ||
| charity.setVerified(); | ||
| assertTrue(charity.isVerified()); | ||
| charity.setUnverified(); | ||
| assertFalse(charity.isVerified()); | ||
| } | ||
|
|
||
| /** | ||
| * totalDonations should display accuratly and adding works | ||
| */ | ||
| @Test | ||
| public void totalDonationsReturnsCorrectlyAfterChanges(){ | ||
| assertEquals(0, charity.getTotalDonations()); | ||
| charity.setTotalDonations(10); | ||
| charity.setTotalDonations(5); | ||
| assertEquals(15, charity.getTotalDonations()); | ||
| } | ||
|
|
||
| } |