Beispiel #1
0
        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));
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 public void Dispose()
 {
     ShortSands.ClearAll();
 }
 public ActionResult DeleteAll()
 {
     ShortSands.ClearAll();
     return(View());
 }
        public ActionResult Index()
        {
            List <ShortSands> allShortSandsComments = ShortSands.GetAll();

            return(View(allShortSandsComments));
        }