Esempio n. 1
0
        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 UnitCountAdjustment()
            {
                Id            = Guid.NewGuid(),
                Date          = new Date(2020, 02, 01),
                Stock         = stock,
                Comment       = "Test Stock Split",
                OriginalUnits = 2,
                NewUnits      = 3
            };

            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 UnitCountAdjustmentHandler();

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

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

            mockRepository.Verify();
        }
Esempio n. 2
0
        public void MultipleParcelsOwned()
        {
            var stock = new Stock(Guid.NewGuid());

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

            var transaction = new UnitCountAdjustment()
            {
                Id            = Guid.NewGuid(),
                Date          = new Date(2020, 02, 01),
                Stock         = stock,
                Comment       = "Test Stock Split",
                OriginalUnits = 2,
                NewUnits      = 3
            };

            var mockRepository = new MockRepository(MockBehavior.Strict);

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

            parcel1.Setup(x => x.Properties[new Date(2020, 02, 01)]).Returns(new ParcelProperties(100, 1000.00m, 1000.00m));
            parcel1.Setup(x => x.Change(new Date(2020, 02, 01), 150, 0.00m, 0.00m, transaction)).Verifiable();
            var parcel2 = mockRepository.Create <IParcel>();

            parcel2.Setup(x => x.Properties[new Date(2020, 02, 01)]).Returns(new ParcelProperties(50, 500.00m, 500.00m));
            parcel2.Setup(x => x.Change(new Date(2020, 02, 01), 75, 0.00m, 0.00m, transaction)).Verifiable();
            var parcel3 = mockRepository.Create <IParcel>();

            parcel3.Setup(x => x.Properties[new Date(2020, 02, 01)]).Returns(new ParcelProperties(200, 1000.00m, 1000.00m));
            parcel3.Setup(x => x.Change(new Date(2020, 02, 01), 300, 0.00m, 0.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[] { parcel1.Object, parcel2.Object, parcel3.Object });

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

            var handler = new UnitCountAdjustmentHandler();

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

            mockRepository.Verify();
        }
Esempio n. 3
0
        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 UnitCountAdjustmentHandler();

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

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

            mockRepository.Verify();
        }