Example #1
0
        public void GetGetDetailedCapitalGainsCapitalGainsStockNotOwnedAtDate()
        {
            var portfolio = PortfolioTestCreator.CreateDefaultPortfolio();

            var service = new PortfolioCapitalGainsService(portfolio);

            var result = service.GetDetailedCapitalGains(PortfolioTestCreator.Stock_ARG.Id, new Date(1999, 01, 01));

            result.Result.UnrealisedGains.Should().BeEmpty();
        }
Example #2
0
        public void GetGetDetailedCapitalGainsCapitalGainsStockNotFound()
        {
            var portfolio = PortfolioTestCreator.CreateDefaultPortfolio();

            var service = new PortfolioCapitalGainsService(portfolio);

            var result = service.GetDetailedCapitalGains(Guid.NewGuid(), new Date(2010, 01, 01));

            result.Should().HaveNotFoundStatus();
        }
Example #3
0
        public void GetGetDetailedCapitalGainsCapitalGainsStockOwnedtDate()
        {
            var portfolio = PortfolioTestCreator.CreateDefaultPortfolio();

            var service = new PortfolioCapitalGainsService(portfolio);

            var result = service.GetDetailedCapitalGains(PortfolioTestCreator.Stock_ARG.Id, new Date(2010, 01, 01));

            result.Result.Should().BeEquivalentTo(new
            {
                UnrealisedGains = new[]
                {
                    new RestApi.Portfolios.DetailedUnrealisedGainsItem()
                    {
                        Stock          = PortfolioTestCreator.Stock_ARG,
                        AquisitionDate = new Date(2000, 01, 01),
                        Units          = 50,
                        CostBase       = 59.97m,
                        MarketValue    = 100m,
                        CapitalGain    = 40.03m,
                        DiscoutedGain  = 20.02m,
                        DiscountMethod = RestApi.Portfolios.CgtMethod.Discount,
                        CGTEvents      =
                        {
                            new RestApi.Portfolios.DetailedUnrealisedGainsItem.CGTEventItem()
                            {
                                Date           = new Date(2000, 01, 01),
                                Description    = "Aquired 100 shares @ $1.00",
                                UnitChange     = 100,
                                Units          = 100,
                                CostBaseChange = 119.95m,
                                CostBase       = 119.95m
                            },
                            new RestApi.Portfolios.DetailedUnrealisedGainsItem.CGTEventItem()
                            {
                                Date           = new Date(2004, 01, 01),
                                Description    = "Disposed of 50 shares @ $1.02",
                                UnitChange     = -50,
                                Units          = 50,
                                CostBaseChange = -59.98m,
                                CostBase       = 59.97m
                            }
                        }
                    },
                    new RestApi.Portfolios.DetailedUnrealisedGainsItem()
                    {
                        Stock          = PortfolioTestCreator.Stock_ARG,
                        AquisitionDate = new Date(2003, 01, 01),
                        Units          = 100,
                        CostBase       = 119.95m,
                        MarketValue    = 200m,
                        CapitalGain    = 80.05m,
                        DiscoutedGain  = 40.03m,
                        DiscountMethod = RestApi.Portfolios.CgtMethod.Discount,
                        CGTEvents      =
                        {
                            new RestApi.Portfolios.DetailedUnrealisedGainsItem.CGTEventItem()
                            {
                                Date           = new Date(2003, 01, 01),
                                Description    = "Aquired 100 shares @ $1.00",
                                UnitChange     = 100,
                                Units          = 100,
                                CostBaseChange = 119.95m,
                                CostBase       = 119.95m
                            }
                        }
                    },
                    new RestApi.Portfolios.DetailedUnrealisedGainsItem()
                    {
                        Stock          = PortfolioTestCreator.Stock_ARG,
                        AquisitionDate = new Date(2005, 01, 01),
                        Units          = 100,
                        CostBase       = 119.95m,
                        MarketValue    = 200m,
                        CapitalGain    = 80.05m,
                        DiscoutedGain  = 40.03m,
                        DiscountMethod = RestApi.Portfolios.CgtMethod.Discount,
                        CGTEvents      =
                        {
                            new RestApi.Portfolios.DetailedUnrealisedGainsItem.CGTEventItem()
                            {
                                Date           = new Date(2005, 01, 01),
                                Description    = "Aquired 100 shares @ $1.00",
                                UnitChange     = 100,
                                Units          = 100,
                                CostBaseChange = 119.95m,
                                CostBase       = 119.95m
                            }
                        }
                    }
                }
            });
        }