Beispiel #1
0
        public async Task CreateThreadAsync_CorrectId_ExpctingRedirectToAction()
        {
            // Arrange
            var threadViewModel  = new Mock <ThreadViewModel>();
            var mockThredService = new Mock <IThreadService>();

            mockThredService.Setup(service => service.CreateAsync(It.IsAny <ThreadViewModel>())).Verifiable();
            var mockUserService  = new Mock <IUserService>();
            var mockAutoMapper   = new Mock <IMapper>();
            var threadController = new ThreadController(mockThredService.Object, mockUserService.Object, mockAutoMapper.Object);

            // Act
            var result = await threadController.CreateThreadAsync(threadViewModel.Object, Guid.NewGuid(), 1, 5);

            // Assert
            var viewResult = Assert.IsAssignableFrom <RedirectToActionResult>(result);

            mockThredService.Verify(service => service.CreateAsync(threadViewModel.Object), Times.Once);
        }