예제 #1
0
        public void ErrorWhenZeroAmountToBeInvested()
        {
            var investor = new Investor
            {
                CurrentValueOfBonds  = 1,
                CurrentValueOfStocks = 1,
                TargetPercentageAllocationToBonds  = 50,
                TargetPercentageAllocationToStocks = 50
            };

            var sut = new NaiveInvestementAllocator();

            Assert.Throws <ArgumentOutOfRangeException>(() => sut.Calculate(0, investor));
        }
예제 #2
0
        public void AllocateAllToBondsWhenUnderweight()
        {
            var investor = new Investor
            {
                CurrentValueOfBonds  = 1,
                CurrentValueOfStocks = 2,
                TargetPercentageAllocationToBonds  = 50,
                TargetPercentageAllocationToStocks = 50
            };

            var sut = new NaiveInvestementAllocator();

            var r = sut.Calculate(100, investor);

            Assert.Equal(100, r.AmountToBonds);
            Assert.Equal(0, r.AmountToStocks);
        }