public void GetAll_ReturnsPosts_AllPosts() { //Arrange string nameOne = "Name1"; string nameTwo = "Name2"; string commentOne = "Comment"; string commentTwo = "Comment"; DateTime timeOne = new DateTime(2019, 05, 07); DateTime timeTwo = new DateTime(2019, 05, 07); ShortSands post1 = new ShortSands(nameOne, commentOne, timeOne); post1.Save(); ShortSands post2 = new ShortSands(nameTwo, commentTwo, timeTwo); post2.Save(); List <ShortSands> newPost = new List <ShortSands> { post1, post2 }; //Act List <ShortSands> allPosts = ShortSands.GetAll(); //Assert CollectionAssert.AreEqual(newPost, allPosts); }
public ActionResult Create(string userName, string userComment, DateTime timePost) { ShortSands newPost = new ShortSands(userName, userComment, timePost); newPost.Save(); List <ShortSands> allPosts = ShortSands.GetAll(); return(View("Index", allPosts)); }
public void Save_AssignsIdToObject_Id() { //Arrange string nameOne = "Name1"; string commentOne = "Comment"; DateTime timeOne = new DateTime(2019, 05, 07); ShortSands testPost = new ShortSands(nameOne, commentOne, timeOne); //Act testPost.Save(); ShortSands savedPost = ShortSands.GetAll()[0]; int result = savedPost.GetId(); int testId = testPost.GetId(); //Assert Assert.AreEqual(testId, result); }
public ActionResult Index() { List <ShortSands> allShortSandsComments = ShortSands.GetAll(); return(View(allShortSandsComments)); }