예제 #1
0
        public async Task <IActionResult> Card(string number)
        {
            int id = await _terminalService.GetCardIdByNumberAsync(number);

            _sessionManager.SetSessionCardId(HttpContext, id);
            return(RedirectToAction(nameof(Pin)));
        }
예제 #2
0
        public async Task GetCardIdByNumberAsyncTests_ShouldReturnId()
        {
            // Arrange
            int    expectedId      = SampleData.CREDITCARDS.First().Id;
            string number          = SampleData.CREDITCARDS.First().Number;
            var    terminalService = new TerminalService(GetCardRepoMock().Object, null, null);

            // Act
            var result = await terminalService.GetCardIdByNumberAsync(number);

            // Assert
            Assert.Equal(expectedId, result);
        }
예제 #3
0
        public async Task GetCardIdByNumberAsyncTests_ShouldThrowInvalOperEx()
        {
            // Arrange
            string number          = SampleData.CREDITCARDS.Where(p => !p.IsValid).First().Number;
            var    terminalService = new TerminalService(GetCardRepoMock().Object, null, null);

            // Act
            Func <Task> action = async() => await terminalService.GetCardIdByNumberAsync(number);

            // Assert
            Exception ex = await Assert.ThrowsAsync <InvalidOperationException>(action);

            Assert.Equal("Card is invalid", ex.Message);
        }
예제 #4
0
        public async Task GetCardIdByNumberAsyncTests_ShouldThrowArgEx()
        {
            // Arrange
            string number          = SampleData.CARD_NOT_ON_THE_LIST.Number;
            var    terminalService = new TerminalService(GetCardRepoMock().Object, null, null);

            // Act
            Func <Task> action = async() => await terminalService.GetCardIdByNumberAsync(number);

            // Assert
            Exception ex = await Assert.ThrowsAsync <ArgumentException>(action);

            Assert.Equal("Card with this number doesn't exist", ex.Message);
        }