public void AssertState(ExchangeDbContext dbContext) { Assert.Equal(Deals.Count, dbContext.Deals.Count()); Assert.Equal(SellOrders.Count, dbContext.SellOrders.Count()); Assert.Equal(BuyOrders.Count, dbContext.BuyOrders.Count()); var hasAllDeals = Deals.All(expectedDeal => dbContext.Deals.Any(actual => actual.Price == expectedDeal.Price && actual.Qty == expectedDeal.Qty && actual.BuyerEmail == expectedDeal.BuyerEmail && actual.SellerEmail == expectedDeal.SellerEmail)); Assert.True(hasAllDeals, "Database should include all expected deals"); var hasAllSellOrders = SellOrders.All(expectedSellOrder => dbContext.SellOrders.Any(actual => expectedSellOrder.Email == actual.Email && expectedSellOrder.Price == actual.Price && expectedSellOrder.Qty == actual.Qty)); Assert.True(hasAllSellOrders, "Database should include all expected sell orders"); var hasAllBuyOrders = BuyOrders.All(expectedBuyOrder => dbContext.BuyOrders.Any(actual => expectedBuyOrder.Email == actual.Email && expectedBuyOrder.Price == actual.Price && expectedBuyOrder.Qty == actual.Qty)); Assert.True(hasAllBuyOrders, "Database should include all expected sell orders"); }