コード例 #1
0
        public void LifoCalculator_NotEnoughSharesByDate()
        {
            //Arrange
            var shares         = new SharesInventory();
            var lifoCalculator = new LifoCalculator();

            //Act
            shares.Purchase(SharesSample[0]);
            shares.Purchase(SharesSample[1]);
            shares.Purchase(SharesSample[2]);
            var result = shares.Sell(120, 10.5, new DateTime(2005, 1, 1), lifoCalculator);

            //Assert
        }
コード例 #2
0
        public void LifoCalculator_Sample()
        {
            //Arrange
            var shares         = new SharesInventory();
            var lifoCalculator = new LifoCalculator();

            //Act
            shares.Purchase(SharesSample[0]);
            shares.Purchase(SharesSample[1]);
            shares.Purchase(SharesSample[2]);
            var result = shares.Sell(120, 10.5, new DateTime(2005, 3, 2), lifoCalculator);

            //Assert
            Assert.AreEqual(10.666, result.CostPriceSoldShares, 0.001);
            Assert.AreEqual(-20, result.GainLossOnSale);
            Assert.AreEqual(70, result.RemainingShares);
            Assert.AreEqual(10.7142, result.CostPriceRemaining, 0.001);
        }