Ejemplo n.º 1
0
        public void CardGet_ShouldClearSession()
        {
            // Arrange
            var sessionManagerMock = new Mock <ITerminalSessionManager>();
            var terminalController = new TerminalController(null, null, sessionManagerMock.Object);

            // Act
            var result = terminalController.Card();

            // Assert
            Assert.NotNull(result);
            Assert.IsAssignableFrom <ViewResult>(result);
            sessionManagerMock.Verify(p => p.ClearSession(It.IsAny <HttpContext>()), Times.Once);
        }
Ejemplo n.º 2
0
        public async Task CardPost_ShouldAddIdToSessionAsync()
        {
            // Arrange
            var terminalServiceMock = new Mock <TerminalService>(null, null, null);

            terminalServiceMock.Setup(p => p.GetCardIdByNumberAsync(TEST_CARD.Number)).ReturnsAsync(TEST_CARD.Id);
            var sessionManagerMock = new Mock <ITerminalSessionManager>();
            var terminalController = new TerminalController(terminalServiceMock.Object, null, sessionManagerMock.Object);

            // Act
            var result = await terminalController.Card(TEST_CARD.Number);

            // Assert
            Assert.NotNull(result);
            Assert.IsAssignableFrom <RedirectToActionResult>(result);
            terminalServiceMock.Verify(p => p.GetCardIdByNumberAsync(TEST_CARD.Number), Times.Once);
            sessionManagerMock.Verify(p => p.SetSessionCardId(It.IsAny <HttpContext>(), TEST_CARD.Id), Times.Once);
        }