public void DisposeOfParcelMoreUnitsThanInParcel()
        {
            var stock = new Stock(Guid.NewGuid());

            stock.List("ABC", "ABC Pty Ltd", new Date(1974, 01, 01), false, AssetCategory.AustralianStocks);

            var holding = new Holding(stock, new Date(2000, 01, 01));
            var parcel  = holding.AddParcel(new Date(2000, 01, 01), new Date(2000, 01, 01), 100, 1000.00m, 1200.00m, null);

            Action a = () => holding.DisposeOfParcel(parcel.Id, new Date(2001, 01, 01), 200, 1000.00m, 10.00m, CgtMethod.Discount, null);

            a.Should().Throw <NotEnoughSharesForDisposal>();
        }
        public void DisposeOfParcelPartialSale()
        {
            var mockRepository = new MockRepository(MockBehavior.Strict);

            var stock = new Stock(Guid.NewGuid());

            stock.List("ABC", "ABC Pty Ltd", new Date(1974, 01, 01), false, AssetCategory.AustralianStocks);

            var          eventSink = mockRepository.Create <ICgtEventSink>();
            CgtEventArgs cgtEvent  = null;

            eventSink.Setup(x => x.OnCgtEventOccured(It.IsAny <Holding>(), It.IsAny <CgtEventArgs>()))
            .Callback <object, CgtEventArgs>((o, e) => cgtEvent = e)
            .Verifiable();

            var holding = new Holding(stock, new Date(2000, 01, 01));

            holding.CgtEventOccurred += eventSink.Object.OnCgtEventOccured;

            var parcel = holding.AddParcel(new Date(2000, 01, 01), new Date(2000, 01, 01), 100, 1000.00m, 1200.00m, null);

            holding.AddParcel(new Date(2000, 01, 01), new Date(2000, 01, 01), 200, 2000.00m, 2200.00m, null);

            var transaction = new Disposal();

            holding.DisposeOfParcel(parcel.Id, new Date(2001, 01, 01), 99, 500.00m, 10.00m, CgtMethod.Discount, transaction);

            using (new AssertionScope())
            {
                holding[new Date(2000, 12, 31)].Should().Be(new HoldingProperties(300, 3000.00m, 3400.00m));
                holding[new Date(2001, 01, 01)].Should().Be(new HoldingProperties(201, 2010.00m, 2212.00m));

                parcel.Properties[new Date(2000, 12, 31)].Should().Be(new ParcelProperties(100, 1000.00m, 1200.00m));
                parcel.Properties[new Date(2001, 01, 01)].Should().Be(new ParcelProperties(1, 10.00m, 12.00m));

                cgtEvent.Should().BeEquivalentTo(new
                {
                    EventDate      = new Date(2001, 01, 01),
                    Stock          = stock,
                    AmountReceived = 500.00m,
                    CapitalGain    = 10.00m,
                    CgtMethod      = CgtMethod.Discount,
                    Transaction    = transaction
                });
            }

            mockRepository.Verify();
        }
        public void DisposeOfParcelNotInHoldings()
        {
            var stock = new Stock(Guid.NewGuid());

            stock.List("ABC", "ABC Pty Ltd", new Date(1974, 01, 01), false, AssetCategory.AustralianStocks);

            var holding = new Holding(stock, new Date(2000, 01, 01));

            holding.AddParcel(new Date(2000, 01, 01), new Date(2000, 01, 01), 100, 1000.00m, 1200.00m, null);

            var parcel = new Parcel(Guid.NewGuid(), new Date(2000, 01, 01), new Date(2000, 01, 01), new ParcelProperties(100, 1000.00m, 1200.00m), null);

            Action a = () => holding.DisposeOfParcel(parcel.Id, new Date(2001, 01, 01), 100, 1000.00m, 500.00m, CgtMethod.Other, null);

            a.Should().Throw <ArgumentException>();
        }