コード例 #1
0
        public void ShouldCreateNewBlockedMoneyItem()
        {
            // Arrange
            SalesService salesService = new SalesService(
                this.operationTableRepository,
                this.balanceTableRepository,
                this.blockedMoneyTableRepository,
                this.sharesNumberTableRepository,
                this.blockedSharesNumberTableRepository,
                this.shareTableRepository);
            BlockedMoneyRegistrationInfo args = new BlockedMoneyRegistrationInfo();

            args.ClientBalance = new BalanceEntity()
            {
                Id     = 45,
                Client = new ClientEntity()
                {
                    Id          = 5,
                    CreatedAt   = DateTime.Now,
                    FirstName   = "John",
                    LastName    = "Snickers",
                    PhoneNumber = "+7956244636652",
                    Status      = true
                },
                Amount = 20000.00M,
                Status = true
            };
            args.Operation = new OperationEntity()
            {
                Id = 2
            };
            args.Total = 10000.00M;

            // Act
            var blockedMoneyId = salesService.CreateBlockedMoney(args);

            // Assert
            blockedMoneyTableRepository.Received(1).Add(Arg.Is <BlockedMoneyEntity>(
                                                            bm => bm.ClientBalance == args.ClientBalance &&
                                                            bm.Operation == args.Operation &&
                                                            bm.Customer == args.ClientBalance.Client &&
                                                            bm.Total == args.Total));
            blockedMoneyTableRepository.Received(1).SaveChanges();
        }