public void Should_amount_is_1200_When_euro_consolidate() { var assetPortfolio = new AssetPortfolio(null); assetPortfolio.Add(new Cash(1000, Currency.EUR)); assetPortfolio.Add(new Cash(200, Currency.EUR)); var result = assetPortfolio.Consolidate(); Assert.AreEqual(1, result.Portfolio.Count); Assert.AreEqual(Currency.EUR, (result.Portfolio[0] as Cash).Currency); Assert.AreEqual(1200, (result.Portfolio[0] as Cash).GetValue()); }
public void Should_price_is_3_and_shares_is_300_When_abc_stock_consolidate() { var assetPortfolio = new AssetPortfolio(null); assetPortfolio.Add(new Stock("ABC", 100, 2, Currency.USD)); assetPortfolio.Add(new Stock("ABC", 200, 3.5, Currency.USD)); var result = assetPortfolio.Consolidate(); Assert.AreEqual(1, result.Portfolio.Count); Assert.AreEqual(3, (result.Portfolio[0] as Stock).Price); Assert.AreEqual(300, (result.Portfolio[0] as Stock).Shares); }
public void TestAddAssetsSameSymbol() { Assert.DoesNotThrow(delegate { var portfolio = new AssetPortfolio(_flatrates, "Test Asset Portfolio"); portfolio.Add(new FXCurrencyAsset("ABC", EUR, 20)); portfolio.Add(new Stock("ABC", EUR, 10, 20)); portfolio.Add(new DomesticStock("ABC", 10, 20)); var consolidated = portfolio.Consolidate(); Assert.AreEqual(portfolio.NoAssets, portfolio.NoDistinctAssets, 3); Assert.AreEqual(consolidated.NoAssets, consolidated.NoDistinctAssets, 3); }); }
public async Task Should_3940_When_call_value_for_cash_and_stocks() { Mock <IExchangeRateService> mockExchangeRateService = new Mock <IExchangeRateService>(); mockExchangeRateService.Setup(x => x.GetRateAsync(It.IsAny <Currency>(), It.IsAny <Currency>())).Returns(Task.FromResult(2.0)); var assetPortfolio = new AssetPortfolio(mockExchangeRateService.Object); assetPortfolio.Add(new Stock("ABC", 100, 5, Currency.USD)); assetPortfolio.Add(new Stock("ABC", 200, 2, Currency.USD)); assetPortfolio.Add(new Cash(1000, Currency.EUR)); assetPortfolio.Add(new Cash(70, Currency.EUR)); var result = await assetPortfolio.ValueAsync(Currency.AUD); Assert.AreEqual(3940, result); }
public void Should_price_is_3_and_shares_is_300_amount_is_1200_x_When_euro_and_abc_stock_consolidate() { var assetPortfolio = new AssetPortfolio(null); assetPortfolio.Add(new Stock("ABC", 100, 2, Currency.USD)); assetPortfolio.Add(new Stock("ABC", 200, 3.5, Currency.USD)); assetPortfolio.Add(new Cash(1000, Currency.EUR)); assetPortfolio.Add(new Cash(200, Currency.EUR)); var result = assetPortfolio.Consolidate(); Assert.AreEqual(2, result.Portfolio.Count); Assert.AreEqual(3, (result.Portfolio[0] as Stock).Price); Assert.AreEqual(300, (result.Portfolio[0] as Stock).Shares); Assert.AreEqual(Currency.EUR, (result.Portfolio[1] as Cash).Currency); Assert.AreEqual(1200, (result.Portfolio[1] as Cash).GetValue()); }