Esempio n. 1
0
        public void ShouldRegisterNewClient()
        {
            //Arrange
            ClientRegistrationInfo args = new ClientRegistrationInfo();

            args.Name  = "Alex Grind";
            args.Phone = "+3 893 212 11 21";
            //Act
            int clientId = clientsService.RegisterNewClient(args);

            //Assert
            clientTableRepository.Received(1).Add(Arg.Is <ClientEntity>(
                                                      s => s.Name == args.Name &&
                                                      s.Phone == args.Phone));
            clientTableRepository.Received(1).SaveChanges();
        }
Esempio n. 2
0
        public void ShouldChangeSellersBalance()
        {
            //Arrange
            TransactionArguments args = new TransactionArguments();

            args.SellerId = 1;
            args.BuyerId  = 2;
            args.SharesId = 1;
            args.Quantity = 5;
            var balanceBeforeChange = clientTableRepository.GetById(1).Balance;
            var sum = sharesTableRepository.GetById(args.SharesId).Price *args.Quantity;

            //Act
            transactionService.MakeTransaction(args);
            //Assert
            clientTableRepository.Received(1).Change(Arg.Is <ClientEntity>(s =>
                                                                           s.Name == "Seller" &&
                                                                           s.Balance == balanceBeforeChange + sum));
            clientTableRepository.Received(1).SaveChanges();
        }