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); }
public void AddStoryTest() { //Arrage var repo = new FakeStoryRepository(); var storyController = new HomeController(repo); //Act //Assert }
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); }
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); }
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); }
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); }
// 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", }; }
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); }
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); }
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); }