public void PopulateStocks_EmptyArray() { // Arrange string[] stockPrices = new string[0]; // Act List <Stock> stocksOutput = StockBuilder.BuildStocks(stockPrices); // Assert stocksOutput.Count.Should().Be(0); }
public void PopulateStocks_EmptyStringArray() { // Arrange // Simulate empty file being loaded string[] stockPrices = new string[] { "" }; try { // Act StockBuilder.BuildStocks(stockPrices); } catch (Exception e) { // Assert e.Message.Should().Contain("The following value: is not valid"); } }
public void PopulateStocks_InvalidDecimal() { // Arrange // Value that can't be parsed as a double string invalidInput = "Test"; string[] stockPrices = new string[] { invalidInput }; try { // Act StockBuilder.BuildStocks(stockPrices); } catch (Exception e) { // Assert e.Message.Should().Contain($"The following value: {invalidInput} is not valid"); } }
public void PopulateStocks_Valid() { // Arrange string stockPrice = "1.0"; string[] stockPrices = { stockPrice }; List <Stock> expectedstocks = new List <Stock> { new Stock { Day = 1, Price = 1.0 } }; // Act List <Stock> actualStocks = StockBuilder.BuildStocks(stockPrices); // Assert expectedstocks.Should().BeEquivalentTo(actualStocks); }