diff --git a/helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/models/CharityTest.java b/helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/models/CharityTest.java index 741f716..7e25bc7 100644 --- a/helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/models/CharityTest.java +++ b/helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/models/CharityTest.java @@ -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()); + } + }