コード例 #1
0
ファイル: Withdraw_Should.cs プロジェクト: ssdody/BedeSlots
        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);
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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());
        }
コード例 #4
0
 public WithdrawTests() : base()
 {
     _logger             = new Mock <ILogger <WithdrawController> >();
     _withdrawController = new WithdrawController(
         _casinoBalanceManager,
         _gameBalanceManager,
         _logger.Object);
 }
コード例 #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);
        }