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

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

            var transaction = new CostBaseAdjustment()
            {
                Id         = Guid.NewGuid(),
                Date       = new Date(2020, 02, 01),
                Stock      = stock,
                Comment    = "Test Costbase Adjustment",
                Percentage = 0.40m,
            };

            var mockRepository = new MockRepository(MockBehavior.Strict);

            var holding = mockRepository.Create <IHolding>();

            holding.Setup(x => x.IsEffectiveAt(new Date(2020, 02, 01))).Returns(false);

            var cashAccount = mockRepository.Create <ICashAccount>();

            var handler = new CostBaseAdjustmentHandler();

            Action a = () => handler.Apply(transaction, holding.Object, cashAccount.Object);

            a.Should().Throw <NoSharesOwnedException>();

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

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

            var transaction = new CostBaseAdjustment()
            {
                Id         = Guid.NewGuid(),
                Date       = new Date(2020, 02, 01),
                Stock      = stock,
                Comment    = "Test Costbase Adjustment",
                Percentage = 0.40m,
            };

            var mockRepository = new MockRepository(MockBehavior.Strict);

            var parcel = mockRepository.Create <IParcel>();

            parcel.Setup(x => x.Properties[new Date(2020, 02, 01)]).Returns(new ParcelProperties(50, 1000.00m, 1500.00m));
            parcel.Setup(x => x.Change(new Date(2020, 02, 01), 0, 0.00m, -900.00m, transaction)).Verifiable();

            var holding = mockRepository.Create <IHolding>();

            holding.Setup(x => x.IsEffectiveAt(new Date(2020, 02, 01))).Returns(true);
            holding.Setup(x => x.Parcels(new Date(2020, 02, 01))).Returns(new IParcel[] { parcel.Object });

            var cashAccount = mockRepository.Create <ICashAccount>();

            var handler = new CostBaseAdjustmentHandler();

            handler.Apply(transaction, holding.Object, cashAccount.Object);

            mockRepository.Verify();
        }
        public void IncorrectTransactionType()
        {
            var transaction = new CashTransaction()
            {
                Id                  = Guid.NewGuid(),
                Date                = new Date(2020, 01, 01),
                Comment             = "Test Deposit",
                CashTransactionType = BankAccountTransactionType.Deposit,
                Amount              = 100.00m
            };

            var mockRepository = new MockRepository(MockBehavior.Strict);

            var holding     = mockRepository.Create <IHolding>();
            var cashAccount = mockRepository.Create <ICashAccount>();

            var handler = new CostBaseAdjustmentHandler();

            Action a = () => handler.Apply(transaction, holding.Object, cashAccount.Object);

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

            mockRepository.Verify();
        }