Skip to content

Commit

Permalink
Added StockTest class
Browse files Browse the repository at this point in the history
  • Loading branch information
elisab3 committed Feb 25, 2026
1 parent 233303b commit d770dbe
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 0 deletions.
Binary file modified target/classes/Exchange.class
Binary file not shown.
Binary file modified target/classes/Portfolio.class
Binary file not shown.
Binary file modified target/classes/Share.class
Binary file not shown.
Binary file modified target/classes/Stock.class
Binary file not shown.
Binary file added target/classes/TransactionCalculator.class
Binary file not shown.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
C:\Users\elisa\Downloads\progdel1\Programmering2_mappe_v26\src\main\java\Exchange.java
C:\Users\elisa\Downloads\progdel1\Programmering2_mappe_v26\src\main\java\Portfolio.java
C:\Users\elisa\Downloads\progdel1\Programmering2_mappe_v26\src\main\java\Share.java
C:\Users\elisa\Downloads\progdel1\Programmering2_mappe_v26\src\main\java\Stock.java
C:\Users\elisa\Downloads\progdel1\Programmering2_mappe_v26\src\main\java\TransactionCalculator.java
37 changes: 37 additions & 0 deletions target/test-classes/StockTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import static org.junit.Assert.assertEquals;

import java.math.BigDecimal;

import org.junit.Test;


public class StockTest {

@Test
public void testGetSalesPrice() {
Stock stock = new Stock("AAPL", "APPLE", new BigDecimal("1000"));
assertEquals(new BigDecimal("1000"), stock.getSalesPrice());
}

@Test
public void testAddNewSalesPrice() {
Stock stock = new Stock("AAPL", "APPLE", new BigDecimal("1000"));
stock.addNewSalesPrice(new BigDecimal("1200"));
assertEquals(new BigDecimal("1200"), stock.getSalesPrice());
}

@Test
public void testGetSalesPriceNone() {
Stock stock = new Stock("AAPL", "APPLE", new BigDecimal("0"));
assertEquals(new BigDecimal("0"), stock.getSalesPrice());
}

@Test
public void testAddNewSalesPriceNone() {
Stock stock = new Stock("AAPL", "APPLE", new BigDecimal("1000"));
stock.addNewSalesPrice(new BigDecimal("0"));
assertEquals(new BigDecimal("0"), stock.getSalesPrice());
}


}

0 comments on commit d770dbe

Please sign in to comment.