public void UpdateHolding_ShouldUpdateHoldingAsync() { int AccountId = 2; string CompanyName = "General Electric Co."; string Symbol = "GE"; int StockCount = 10; float LatestCostPerStock = 10.95F; float Change = -0.33F; float ChangePercentage = -0.02957F; var LastUpdated = DateTime.Now; var Holding = new List <Holdings> { new Holdings { Id = 2, AccountId = AccountId, CompanyName = CompanyName, Symbol = Symbol, StockCount = 5, LatestCostPerStock = 10.65F, Change = Change, ChangePercentage = ChangePercentage, LastUpdated = LastUpdated } }; _session.Query <Holdings>().Returns(Holding.AsQueryable()); _sut.UpdateHolding(AccountId, Symbol, StockCount, LatestCostPerStock, LastUpdated); Assert.That(Holding[0].StockCount == StockCount && Holding[0].LatestCostPerStock == LatestCostPerStock); }
public async Task UpdateHolding(JObject data) { var AccountId = Int32.Parse(data["AccountId"].ToString()); var CompanyName = data["CompanyName"].ToString(); var Symbol = data["Symbol"].ToString(); var StockCount = Int32.Parse(data["StockCount"].ToString()); var LatestCostPerStock = float.Parse(data["LatestCostPerStock"].ToString()); var Change = float.Parse(data["Change"].ToString()); var ChangePercentage = float.Parse(data["ChangePercentage"].ToString()); var LastUpdated = DateTime.Now; if (_holdingsService.HoldingExists(AccountId, Symbol)) { if (StockCount == 0) { await _holdingsService.DeleteHolding(AccountId, Symbol); } else { await _holdingsService.UpdateHolding(AccountId, Symbol, StockCount, LatestCostPerStock, LastUpdated); } } else { await _holdingsService.NewHolding(AccountId, CompanyName, Symbol, StockCount, LatestCostPerStock, Change, ChangePercentage, LastUpdated); } }