Example #1
0
        public void GetStoryByTitleTest()
        {
            //arrange
            var repo4 = new FakeStoryRepository();

            //act
            StoryResponse fetchedStory = repo4.GetStoryByTitle("Ghandi goes on hunger strike");

            //assert, checking a random property of the fetchedStory is equal to that same property in the test data
            Assert.Equal("April 9th, 1908", fetchedStory.Date);
        }
Example #2
0
        public void AddComment()
        {
            var repo       = new FakeStoryRepository();
            var controller = new HomeController(repo);

            Story s = repo.GetStoryByTitle("Patton's first day");


            var result = controller.AddComment(s.Title);
            var model  = ((Microsoft.AspNetCore.Mvc.ViewResult)result).Model as String;

            Assert.Equal("Patton's first day", model);
        }
Example #3
0
        public void AddStoryTest()
        {
            // add new story object
            controller.HappyTail(story);

            // Assert new story object was added to fake repo
            // while simultaneously testing GetStoryByTitle()
            Story retrievedStory = fakeRepo.GetStoryByTitle("Pineapple");

            Assert.Equal(story, retrievedStory);

            // Assert date was added to story object
            Assert.Equal(0, DateTime.Now.Date.CompareTo(retrievedStory.Date.Date));
        }