@Test public void simulationStatusShouldBeSimulationUninitialised() { // given when StockExchange stockExchange = new StockExchange(); // then assertEquals(SimulationStatus.SIMULATION_UNINITIALISED, stockExchange.getSimulationStatus()); }
@Test public void simulationStatusShouldBeSimulationFinishedAfterInitialising() throws DateTimeParseException, FileNotFoundException, IOException { // given Mockito.doNothing().when(dataProvider).readDataFromFile(Mockito.anyString()); Mockito.when(dataProvider.getEarliestDate()).thenReturn(LocalDate.parse("2013-12-30")); Mockito.when(dataProvider.getLatestDate()).thenReturn(LocalDate.parse("2013-01-02")); // when stockExchange.initialise("Test"); // then Mockito.verify(dataProvider).readDataFromFile(Mockito.anyString()); assertEquals(SimulationStatus.SIMULATION_FINISHED, stockExchange.getSimulationStatus()); }
@Test public void nextDayShouldIncrementDateAndCallGetStockByDate() throws DateTimeParseException, FileNotFoundException, IOException { // given Mockito.doNothing().when(dataProvider).readDataFromFile(Mockito.anyString()); Mockito.when(dataProvider.getEarliestDate()).thenReturn(LocalDate.parse("2013-01-02")); Mockito.when(dataProvider.getLatestDate()).thenReturn(LocalDate.parse("2013-01-07")); Mockito.when(dataProvider.getStocksByDate(Mockito.any())) .thenReturn( Arrays.asList( new Stock("TPSA", LocalDate.parse("2013-01-03"), new BigDecimal("12.13")))); stockExchange.initialise("Test"); // when stockExchange.nextDay(); // then Mockito.verify(dataProvider).getStocksByDate(LocalDate.parse("2013-01-03")); assertEquals(SimulationStatus.SIMULATION_NOT_FINISHED, stockExchange.getSimulationStatus()); }