Esempio n. 1
0
        public void AddStoryTest()
        {
            //arrange
            StoryResponse story = new StoryResponse()
            {
                Title = "Test title",
                Date  = "test date",
                Text  = "test text"
            };

            story.Author = new User()
            {
                Username = "******"
            };
            var repo2 = new FakeStoryRepository();

            //act
            repo2.AddStory(story);

            //assert, could add a comparer to simply this assertion to one line
            Assert.Equal("Test title", repo2.Stories.Last().Title);
            Assert.Equal("test date", repo2.Stories.Last().Date);
            Assert.Equal("test text", repo2.Stories.Last().Text);
            Assert.Equal("Mr. Test", repo2.Stories.Last().Author.Username);
        }
Esempio n. 2
0
 public void AddStoryTest()
 {
     //Arrage
     var repo            = new FakeStoryRepository();
     var storyController = new HomeController(repo);
     //Act
     //Assert
 }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public void StoryContructorTest()
        {
            //arrange
            var repo1 = new FakeStoryRepository();

            //act
            //no actions needed, repo should have one story added by the class constructor

            //assert, first story title should be Ghandi "goes on hunger strike"
            Assert.Equal("Ghandi goes on hunger strike", repo1.Stories.Last().Title);
        }
Esempio n. 5
0
        public void Stories()
        {
            //tests to see that the view receives a list of stories sorted by title
            var repo       = new FakeStoryRepository();
            var controller = new HomeController(repo);

            var result = controller.Stories();
            var model  = ((Microsoft.AspNetCore.Mvc.ViewResult)result).Model as List <Story>;

            Assert.Equal("Guess Who Ate the Pansies", model[0].Title);
        }
Esempio n. 6
0
        public void AddStoryViewTest()
        {
            //arrange
            var repo3      = new FakeStoryRepository();
            var controller = new StoryController(repo3);

            //act
            controller.Stories("Ghandi meets with the Prime Minister", "Carl Sagan", "April 5th, 1968", "The meeting went very poorly.");

            //Assert
            Assert.Equal("Ghandi meets with the Prime Minister", repo3.Stories.Last().Title);
        }
Esempio n. 7
0
 // constructor behaves the same as [SetUp]
 public StoryTests()
 {
     fakeRepo   = new FakeStoryRepository();
     controller = new RescueController(userManager, fakeRepo);
     story      = new Story()
     {
         Title = "Pineapple",
         //User = new AppUser() { UserName = "******" },
         Text     = "Lorem ipsum dolor sit amet",
         Filename = "30721.jpg",
     };
 }
Esempio n. 8
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);
        }
Esempio n. 9
0
        public void StoriesForm()
        {
            //Arrange
            var   repo       = new FakeStoryRepository();
            var   controller = new HomeController(repo);
            Story s          = new Story()
            {
                Name      = "TestStory",
                Title     = "TheTitle",
                Date      = "1/5/18",
                StoryText = "Here is the story."
            };

            //Act
            controller.StoriesForm(s);

            //Assert
            Assert.Equal("TestStory", repo.Stories[repo.Stories.Count - 1].Name);
        }
Esempio n. 10
0
        public void PostAddComment()
        {
            var repo       = new FakeStoryRepository();
            var controller = new HomeController(repo);

            User u = new User
            {
                Name = "Fake User"
            };

            Comment c = new Comment()
            {
                CommentText = "Test Comment",
                Contributor = u,
            };

            controller.AddComment("Patton's first day", c.CommentText, c.Contributor.Name);

            Assert.Equal("Fake User", repo.Stories[0].Comments[0].Contributor.Name);
        }