Skip to content

Commit

Permalink
Update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
JosueNina committed Jan 23, 2025
1 parent 9130e56 commit ebba66c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Tests/Algorithm/AlgorithmTradingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1362,15 +1362,17 @@ public void SetHoldingsReturnsOrderTicketsTest(List<Symbol> symbols, bool liquid
}
}

var applTicket = orderTickets.Where(x => x.Symbol == Symbols.AAPL).FirstOrDefault();
var ibmTicket = orderTickets.Where(x => x.Symbol == Symbols.IBM).FirstOrDefault();
var spyTicket = orderTickets.Where(x => x.Symbol == Symbols.SPY).FirstOrDefault();

// Assert that ticket quantities and total order tickets match the expected values
Assert.AreEqual(applTicket?.Quantity ?? 0, expectedOrders.GetValueOrDefault(Symbols.AAPL));
Assert.AreEqual(ibmTicket?.Quantity ?? 0, expectedOrders.GetValueOrDefault(Symbols.IBM));
Assert.AreEqual(spyTicket?.Quantity ?? 0, expectedOrders.GetValueOrDefault(Symbols.SPY));
// Assert that the number of tickets matches the expected count
Assert.AreEqual(expectedOrders.Count, orderTickets.Count);

// Check each ticket:
// 1. Ensure the symbol is in the expectedOrders dictionary.
// 2. Verify the quantity matches the expected value for that symbol.
foreach (var ticket in orderTickets)
{
Assert.IsTrue(expectedOrders.ContainsKey(ticket.Symbol));
Assert.AreEqual(expectedOrders[ticket.Symbol], ticket.Quantity);
}
}

[Test]
Expand Down

0 comments on commit ebba66c

Please sign in to comment.