コード例 #1
0
        public async Task PostShouldAddAnalysisAsync()
        {
            //arrange
            var mockRepo          = new Mock <IRepository>();
            var inputVideoHistory = new VideoHistory()
            {
                Email    = "*****@*****.**",
                VideoUrl = "ABC",
                AverageSentimentScore = 0.5,
                ChannelName           = "Mathemars"
            };
            var controller = new UserSentimentHistoryController(mockRepo.Object);

            //act
            var result = await controller.PostAsync(inputVideoHistory);

            //assert
            Assert.IsAssignableFrom <CreatedAtActionResult>(result);
        }
コード例 #2
0
        public async Task PostShouldHandleRequestsAsync()
        {
            //arrange
            var mockRepo = new Mock <IRepository>();

            mockRepo.Setup(x => x.AddAnalysisAsync(It.IsAny <AverageSentiment>(), It.IsAny <Creator>())).Throws(new Persistence.CreatorDoesNotExistException());
            var inputVideoHistory = new VideoHistory()
            {
                Email    = "*****@*****.**",
                VideoUrl = "ABC",
                AverageSentimentScore = 0.5,
                ChannelName           = "Mathemars"
            };
            var controller = new UserSentimentHistoryController(mockRepo.Object);

            //act
            var result = await controller.PostAsync(inputVideoHistory);

            //assert
            Assert.IsAssignableFrom <BadRequestResult>(result);
        }