public void StoriesController_Get_Should_Return_StatusCode_200()
        {
            //Arrange
            int extectedResult = 200;
            //Act
            var actualResult = (ObjectResult)_storiesController.Get().Result;

            //Assert
            Assert.AreEqual(extectedResult, actualResult.StatusCode);
        }
        public void Returns_data_From_Service_verbatim()
        {
            //Arrange
            var stories = new []
            {
                new Story(),
                new Story(),
                new Story()
            };
            var service = new Mock <IStoryService>();

            service
            .Setup(fake => fake.GetAllAsync())
            .ReturnsAsync(stories);

            var controller = new StoriesController(service.Object);

            //Act
            var result = controller.Get().Result;

            //Assert
            service.Verify(mock => mock.GetAllAsync(), Times.Once);
            Assert.AreEqual(stories.Count(), result.Count());
            Assert.AreEqual(stories.First(), result.First());
        }
        public void ReturnsNotFoundIfStoryNotExists()
        {
            Mock <IStoryService> storyService = new Mock <IStoryService>();

            storyService.Setup(s => s.GetStory(1)).Returns <Story>(null);
            StoriesController storiesController = new StoriesController(storyService.Object, null);

            var result = storiesController.Get(1);

            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
        public void ReturnsAStoryById()
        {
            Mock <IStoryService> storyService = new Mock <IStoryService>();

            storyService.Setup(s => s.GetStory(1)).Returns(new StoryBuilder().WithTitle("title 1"));
            StoriesController storiesController = new StoriesController(storyService.Object, null);

            var result = storiesController.Get(1) as OkNegotiatedContentResult <StoryResponse>;

            Assert.IsNotNull(result);
            Assert.AreEqual("title 1", result.Content.Title);
        }
        public void Get_Should_Return_A_Story()
        {
            var mockService = new Mock <IStoryService>();

            mockService.Setup(ms => ms.GetStory()).Returns("This is my story");

            var storiesController = new StoriesController(mockService.Object);

            var result = storiesController.Get();

            Assert.NotEmpty(result);
        }
Beispiel #6
0
        public async Task TestGetWhenCalledReturnsOkResult()
        {
            var result = await _controller.Get(_parameters);

            Assert.IsInstanceOf <ActionResult <StoryResponse> >(result);
        }