Skip to content

File structure fix #36

Merged
merged 1 commit into from
Feb 11, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed src/test/java/ExchangeTest.java
Empty file.
Empty file removed src/test/java/PlayerTest.java
Empty file.
Empty file removed src/test/java/PortfolioTest.java
Empty file.
Empty file removed src/test/java/PurchaseTest.java
Empty file.
Empty file.
Empty file removed src/test/java/SaleTest.java
Empty file.
Empty file removed src/test/java/ShareTest.java
Empty file.
Empty file removed src/test/java/StockTest.java
Empty file.
Empty file.
Empty file removed src/test/java/TransactionTest.java
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class ExchangeTest {

}
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
public class MainTest {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class PlayerTest {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class PortfolioTest {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class PurchaseTest {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class SaleCalculatorTest {

}
3 changes: 3 additions & 0 deletions src/test/java/edu/ntnu/idi/idatt2003/g40/mappe/SaleTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class SaleTest {

}
3 changes: 3 additions & 0 deletions src/test/java/edu/ntnu/idi/idatt2003/g40/mappe/ShareTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class ShareTest {

}
58 changes: 58 additions & 0 deletions src/test/java/edu/ntnu/idi/idatt2003/g40/mappe/StockTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package edu.ntnu.idi.idatt2003.g40.mappe;

import org.junit.jupiter.api.Test;

import java.math.BigDecimal;
import java.util.NoSuchElementException;

import static org.junit.jupiter.api.Assertions.*;

class StockTest {

@Test
void constructor_setsSymbolAndCompany() {
Stock stock = new Stock("AAPL", "Apple Inc.", new BigDecimal("100.00"));

assertEquals("AAPL", stock.getSymbol());
assertEquals("Apple Inc.", stock.getCompany());
}

@Test
void getSalesPrice_throwsWhenNoPricesExist_currentImplementation() {
Stock stock = new Stock("AAPL", "Apple Inc.", new BigDecimal("100.00"));

// Because constructor does not add the initial salesPrice to prices,
// prices is empty and getLast() throws NoSuchElementException.
assertThrows(NoSuchElementException.class, stock::getSalesPrice);
}

@Test
void addNewSalesPrice_thenGetSalesPrice_returnsLastAddedPrice() {
Stock stock = new Stock("AAPL", "Apple Inc.", new BigDecimal("100.00"));

stock.addNewSalesPrice(new BigDecimal("123.45"));

assertEquals(new BigDecimal("123.45"), stock.getSalesPrice());
}

@Test
void addNewSalesPrice_twice_getSalesPrice_returnsMostRecent() {
Stock stock = new Stock("AAPL", "Apple Inc.", new BigDecimal("100.00"));

stock.addNewSalesPrice(new BigDecimal("10.00"));
stock.addNewSalesPrice(new BigDecimal("20.00"));

assertEquals(new BigDecimal("20.00"), stock.getSalesPrice());
}

@Test
void addNewSalesPrice_allowsNull_currentImplementation() {
Stock stock = new Stock("AAPL", "Apple Inc.", new BigDecimal("100.00"));

stock.addNewSalesPrice(null);

// List allows nulls; getLast returns null -> should not throw.
assertDoesNotThrow(stock::getSalesPrice);
assertNull(stock.getSalesPrice());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class TransactionArchiveTest {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class TransactionTest {

}
Loading