Skip to content

Commit

Permalink
File structure fix
Browse files Browse the repository at this point in the history
The file structure was configured in a way that caused a package bug. This should fix the problem
  • Loading branch information
EspenTinius committed Feb 11, 2026
1 parent ef6d943 commit b7e5824
Show file tree
Hide file tree
Showing 22 changed files with 86 additions and 0 deletions.
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 {

}
File renamed without changes.
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 {

}

0 comments on commit b7e5824

Please sign in to comment.