Example #1
0
        public async Task ShouldReturnOkResultWhenValidModelPassed()
        {
            //Arrange
            var model = new FeedDTO();

            MockFeedService.Setup(x => x.AddFeed(It.IsAny <FeedDTO>()))
            .Returns(Task.FromResult(new Response <FeedReadDto>()
            {
                Success = true
            }));
            var feedController = new FeedController(_serviceProvider);

            var expected = 201;

            //ACT
            var actual = await feedController.CreateFeed(model) as CreatedResult;

            //Assert
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected, actual.StatusCode);
        }
Example #2
0
        public async Task ShouldReturnBadRequestWhenIdNotValid()
        {
            //Arrange
            var id = Guid.NewGuid().ToString();

            MockFeedService.Setup(x => x.DeleteFeed(It.IsAny <string>()))
            .Returns(Task.FromResult(new Response <string>()
            {
                Success = false
            }));
            var feedController = new FeedController(_serviceProvider);

            var expected = 400;

            //Act
            var actual = await feedController.RemoveFeed(id) as BadRequestObjectResult;

            //Assert
            // Assert.IsNotNull(actual);
            Assert.AreEqual(expected, actual.StatusCode);
        }
Example #3
0
        public async Task ShouldReturnNoContentIfEditSuccessful()
        {
            //Arrange
            var model = new FeedDTO();
            var id    = Guid.NewGuid().ToString();

            MockFeedService.Setup(x => x.EditFeed(It.IsAny <string>(), It.IsAny <FeedDTO>()))
            .Returns(Task.FromResult(new Response <string>()
            {
                Success = true
            }));
            var feedController = new FeedController(_serviceProvider);

            var expected = 204;

            //Act
            var actual = await feedController.ModifyFeed(id, model) as NoContentResult;

            //Assert
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected, actual.StatusCode);
        }