Beispiel #1
0
 private void ExecuteBuy(User user, FillDetail[] fills)
 {
     _holdingsProvider.TransferHoldingsToUser(user, fills);
     _bankingProvider.TransferFundsToHolders(user, fills);
     _ordersProvider.UpdateOrders(fills);
     _sharesProvider.UpdateStock(fills);
 }
Beispiel #2
0
        public void TransferHoldingsToUserTest()
        {
            var fills = new[]
            {
                new FillDetail
                {
                    Owner = new User {
                        UserId = Guid.NewGuid()
                    },
                    Stock    = _stock,
                    Quantity = 5
                },
                new FillDetail
                {
                    Owner = new User {
                        UserId = Guid.NewGuid()
                    },
                    Stock    = _stock,
                    Quantity = 7
                },
            };

            _provider.CreateUser(_user);
            _provider.AddHolding(_user, _stock, 3);
            _provider.CreateUser(fills[0].Owner);
            _provider.AddHolding(fills[0].Owner, _stock, 5);
            _provider.CreateUser(fills[1].Owner);
            _provider.AddHolding(fills[1].Owner, _stock, 7);

            _provider.TransferHoldingsToUser(_user, fills);

            var userHoldings  = _provider.GetHolding(_user, _stock);
            var fill1Holdings = _provider.GetHolding(fills[0].Owner, _stock);
            var fill2Holdings = _provider.GetHolding(fills[1].Owner, _stock);

            Assert.AreEqual(15, userHoldings);
            Assert.AreEqual(0, fill1Holdings);
            Assert.AreEqual(0, fill2Holdings);
        }