Example #1
0
        public static RestApi.Transactions.Aquisition ToResponse(this Domain.Transactions.Aquisition aquisition)
        {
            var response = new RestApi.Transactions.Aquisition();

            PopulatePortfolioTransaction(response, aquisition);

            response.AveragePrice          = aquisition.AveragePrice;
            response.CreateCashTransaction = aquisition.CreateCashTransaction;
            response.TransactionCosts      = aquisition.TransactionCosts;
            response.Units = aquisition.Units;

            return(response);
        }
Example #2
0
        public void AquisitionToResponse()
        {
            var mockRepository = new MockRepository(MockBehavior.Strict);

            var stock = mockRepository.Create <IReadOnlyStock>();

            stock.SetupGet(x => x.Id).Returns(Guid.NewGuid());

            var aquisition = new Domain.Transactions.Aquisition()
            {
                Id                    = Guid.NewGuid(),
                Date                  = new Date(2001, 01, 01),
                Stock                 = stock.Object,
                Comment               = "Test",
                Units                 = 10,
                AveragePrice          = 1.20m,
                TransactionCosts      = 19.95m,
                CreateCashTransaction = false
            };

            var response = aquisition.ToResponse();

            response.Should().BeEquivalentTo(new
            {
                Id                    = aquisition.Id,
                Type                  = RestApi.Transactions.TransactionType.Aquisition,
                Stock                 = stock.Object.Id,
                TransactionDate       = new Date(2001, 01, 01),
                Comment               = "Test",
                Description           = "Aquired 10 shares @ $1.20",
                Units                 = 10,
                AveragePrice          = 1.20m,
                TransactionCosts      = 19.95m,
                CreateCashTransaction = false
            });
        }