Skip to content

Commit

Permalink
Feat: Added UnitTest for Charity class with JavaDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBalunan committed Mar 3, 2026
1 parent ab584ac commit 7e62703
Showing 1 changed file with 64 additions and 0 deletions.
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());
}

}

0 comments on commit 7e62703

Please sign in to comment.