Ejemplo n.º 1
0
        public void HasBeenAppliedResultStocksNoTransactionsAtImplementationDate()
        {
            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 stock2 = new Stock(Guid.NewGuid());

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

            var resultStocks = new Transformation.ResultingStock[] {
                new Transformation.ResultingStock(stock2.Id, 1, 1, 10.00m, new Date(2020, 02, 01))
            };
            var transformation = new Transformation(Guid.NewGuid(), stock, new Date(2020, 01, 01), "Test Transformation", new Date(2020, 02, 01), 0.00m, true, resultStocks);

            var transactions = mockRepository.Create <IPortfolioTransactionList>();

            transactions.Setup(x => x.ForHolding(stock2.Id, transformation.ImplementationDate)).Returns(new IPortfolioTransaction[] { });

            var result = transformation.HasBeenApplied(transactions.Object);

            result.Should().BeFalse();

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

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

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

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

            CompositeActionAddedEvent @event = null;
            var id      = Guid.NewGuid();
            var builder = new CompositeActionBuilder(stock, id, new Date(2000, 01, 01), "Test Composite Action", (x) => { @event = x; });

            var resultStocks = new Transformation.ResultingStock[] {
                new Transformation.ResultingStock(stock2.Id, 1, 2, 0.40m, new Date(2020, 02, 01))
            };

            builder.AddTransformation("Test Transformation", new Date(2000, 02, 01), 1.20m, false, resultStocks)
            .Finish();

            using (new AssertionScope())
            {
                @event.Should().BeEquivalentTo(
                    new
                {
                    EntityId    = stock.Id,
                    Version     = 1,
                    ActionId    = id,
                    ActionDate  = new Date(2000, 01, 01),
                    Description = "Test Composite Action"
                });
                @event.ChildActions.Should().SatisfyRespectively(

                    first =>
                {
                    first.Should().BeOfType <TransformationAddedEvent>();
                    if (first is TransformationAddedEvent transformation)
                    {
                        transformation.EntityId.Should().Be(stock.Id);
                        transformation.Version.Should().Be(1);
                        transformation.ActionDate.Should().Be(new Date(2000, 01, 01));
                        transformation.Description.Should().Be("Test Transformation");
                        transformation.ImplementationDate.Should().Be(new Date(2000, 02, 01));
                        transformation.CashComponent.Should().Be(1.20m);
                        transformation.RolloverRefliefApplies.Should().BeFalse();
                        transformation.ResultingStocks.Should().HaveCount(1);
                    }
                }
                    );
            };
        }