public void getByPostAndUserTest()
        {
            initiaizeTest();
            var annotation = _annoRepository.GetByPostAndUser(105975, 72);

            var actual = new Annotation { Id=4,PostId= 105975,UserId=72,Body="0",Date= DateTime.Parse("2011-10-04 01:01:00") };
            Assert.AreEqual(annotation.Id, actual.Id);
            Assert.AreEqual(annotation.Body, actual.Body);
            Assert.AreEqual(annotation.PostId, actual.PostId);
            Assert.AreEqual(annotation.UserId, actual.UserId);
            Assert.AreEqual(annotation.Date, actual.Date);
        }
 public void InsertTest()
 {
     initiaizeTest();
     Random rdm = new Random();
     int id = rdm.Next(10000);
     int postid = rdm.Next(10000);
     int userid = rdm.Next(10000);
     Annotation expected = new Annotation
     {
         Id = id,
         UserId = userid,
         PostId = postid,
         Body = "annotation unit test , postid = " + postid + " userid = " + userid,
         Date = DateTime.Now
     };
     int count = _annoRepository.Insert(expected);
     Annotation actual = _annoRepository.GetByPostAndUser(postid, userid);
     Assert.IsTrue(expected.PostId == actual.PostId);
     Assert.IsTrue(expected.UserId == actual.UserId);
 }
Example #3
0
        public AnnotationModel Create(Annotation annotation)
        {
            return new AnnotationModel
            {
                Url = _urlHelper.Link("AnnotationByIdApi", new { id = annotation.Id }),
                Body = annotation.Body,
                Date = DateTime.Now,
                UserId = annotation.UserId,
                PostId = annotation.PostId

            };
        }