public void GetFeedbacks_should_return_all_feedbacks()
        {
            // Act
            var results = Controller.GetFeedbacks().GetAwaiter().GetResult();

            // Assert
            Assert.AreEqual(results.Value.Count, Repository.Get().GetAwaiter().GetResult().Count);
        }
Beispiel #2
0
        public async Task Success_FeedbackController_GetFeedbacks_BadRequest_When_Rating_Filtering_OutOfRange()
        {
            //Arrange
            _mockFeedbackService.Setup(service => service.GetSessionFeedbacksAsync(It.IsAny <short>()))
            .ReturnsAsync(_sessionFeedbacks);

            //Act
            var feedbackController = new FeedbackController(_mockLogger.Object, _mockFeedbackService.Object);
            var action             = await feedbackController.GetFeedbacks(6);

            //Assert
            Assert.IsType <BadRequestResult>(action.Result);
            _mockFeedbackService.Verify(service => service.GetSessionFeedbacksAsync(It.IsAny <short>()), Times.Never);
        }
Beispiel #3
0
        public async Task Success_FeedbackController_GetFeedbacks_OK_When_With_Rating_Filtering()
        {
            //Arrange
            _mockFeedbackService.Setup(service => service.GetSessionFeedbacksAsync(It.IsAny <short>()))
            .ReturnsAsync(_sessionFeedbacks);

            //Act
            var feedbackController = new FeedbackController(_mockLogger.Object, _mockFeedbackService.Object);
            var action             = await feedbackController.GetFeedbacks((short)new Random().Next(1, 5));

            var result    = action.Result as ObjectResult;
            var feedbacks = result.Value as List <SessionFeedback>;

            //Assert
            Assert.IsType <OkObjectResult>(result);
            _mockFeedbackService.Verify(service => service.GetSessionFeedbacksAsync(It.IsAny <short>()), Times.Once);
            Assert.Equal(_sessionFeedbacks, feedbacks);
        }