Exemple #1
0
        private WithdrawController SetupController(Mock <ICardService> cardServiceMock,
                                                   Mock <IUserBalanceService> userBalanceServiceMock,
                                                   Mock <ITransactionService> transactionerviceMock,
                                                   Mock <UserManager <User> > userManagerMock,
                                                   Mock <ICurrencyService> curencyServiceMock)
        {
            var controller = new WithdrawController(
                userBalanceServiceMock.Object,
                transactionerviceMock.Object,
                cardServiceMock.Object,
                curencyServiceMock.Object,
                userManagerMock.Object)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                    {
                        User = new ClaimsPrincipal()
                    }
                },
                TempData = new Mock <ITempDataDictionary>().Object
            };;

            return(controller);
        }
        public async Task Create_WithdrawNonExistingAccount_ShouldReturnNotFound()
        {
            var request = new WithdrawCreateRequest
            {
                AccountId  = 1,
                Ammount    = 100,
                CustomerId = 2,
                Details    = "Test",
            };

            _mockMediator
            .Setup(m => m.Send(It.Is <WithdrawCreateRequest>(t => t.AccountId == request.AccountId &&
                                                             t.Ammount == request.Ammount &&
                                                             t.CustomerId == request.CustomerId &&
                                                             t.Details == request.Details), default))
            .ThrowsAsync(new NotFoundException())
            .Verifiable();

            var controller = new WithdrawController(_mockMediator.Object);

            var result = await controller.Create(request);

            _mockMediator.Verify();

            Assert.True(typeof(NotFoundObjectResult) == result.Result.GetType());
        }
        public async Task Create_WithdrawExistingAccount_ShouldReturnTransactions()
        {
            var request = new WithdrawCreateRequest
            {
                AccountId  = 1,
                Ammount    = 100,
                CustomerId = 2,
                Details    = "Test",
            };

            var transferTransactions = WithdrawTransactions(request);

            _mockMediator
            .Setup(m => m.Send(It.Is <WithdrawCreateRequest>(t => t.AccountId == request.AccountId &&
                                                             t.Ammount == request.Ammount &&
                                                             t.CustomerId == request.CustomerId &&
                                                             t.Details == request.Details), default))
            .ReturnsAsync(transferTransactions)
            .Verifiable();

            var controller = new WithdrawController(_mockMediator.Object);

            var result = await controller.Create(request);

            _mockMediator.Verify();

            Assert.True(typeof(CreatedAtActionResult) == result.Result.GetType());
        }
 public WithdrawTests() : base()
 {
     _logger             = new Mock <ILogger <WithdrawController> >();
     _withdrawController = new WithdrawController(
         _casinoBalanceManager,
         _gameBalanceManager,
         _logger.Object);
 }
Exemple #5
0
        public void Setup()
        {
            _fileSystem = new FileSystem();
            if (!Directory.Exists(SafeDepositLocationDirectory))
            {
                Directory.CreateDirectory(SafeDepositLocationDirectory);
            }

            SetTransactions();
            _controller = new WithdrawController(new AccountTransactions(_fileSystem), new SendMessage(new NotificationStrategyFactory()));
        }
        public void WithdrawControllerInitializationTest_ChecksIfTheControllerInitializesAsExpected_VerifiesThroughInstance()
        {
            WithdrawController withdrawController = (WithdrawController)ContextRegistry.GetContext()["WithdrawController"];

            Assert.IsNotNull(withdrawController);
        }