コード例 #1
0
 public void UserComments()
 {
     UserCommentsController controller = new UserCommentsController();
     var result = controller.Details(1);
     Assert.IsNotNull(result);
     Assert.IsInstanceOfType(result, typeof(object));
 }
コード例 #2
0
 public void UserCommentsDetailsNew()
 {
     UserCommentsController controller = new UserCommentsController();
     var result = (HttpStatusCodeResult)controller.Details(-1);
     Assert.AreEqual(404, result.StatusCode);
     Assert.IsInstanceOfType(result, typeof(HttpStatusCodeResult));
 }
コード例 #3
0
        public void UserCommentsIndex()
        {
            UserCommentsController controller = new UserCommentsController();
            var result = controller.Index();
            Assert.IsInstanceOfType(result, typeof(ViewResult));

        }
コード例 #4
0
        public void UserCommentsCreateInvalidInput()
        {
            UserCommentsController controller = new UserCommentsController();
            UserComment uc = new UserComment();
            uc.UserCommentId = 1;
            uc.AccomodationId = 1;
            uc.Comment = "Some new comment";
            uc.ApplicationUserId = "12345";
            uc.UserName = "******";
            uc.Rating = -2;
            uc.ReportCount = -5;


            var context = new ValidationContext(uc, null, null);
            var results = new List<ValidationResult>();
            TypeDescriptor.AddProviderTransparent(new AssociatedMetadataTypeTypeDescriptionProvider(typeof(UserComment), typeof(UserComment)), typeof(UserComment));

            var isModelStateValid = Validator.TryValidateObject(uc, context, results, true);
            Assert.AreEqual(false, isModelStateValid);

        }
コード例 #5
0
 public void CreateValidate()
 {
     UserCommentsController controller = new UserCommentsController();
     var result = controller.Create() as ViewResult;
     var newResult = controller.Create();
     Assert.IsInstanceOfType(newResult, typeof(ViewResult));
 }
コード例 #6
0
 public void UserCommentsDelete()
 {
     UserCommentsController controller = new UserCommentsController();
     var result = controller.Delete(1);
     Assert.IsNotNull(result);
 }
コード例 #7
0
 public void UserCommentsDeleteNull()
 {
     UserCommentsController controller = new UserCommentsController();
     var result = (HttpStatusCodeResult)controller.Delete(null);
     Assert.AreEqual(400, result.StatusCode);
     Assert.IsInstanceOfType(result, typeof(HttpStatusCodeResult));
 }
コード例 #8
0
        public void UserCommentsEditId()
        {
            UserCommentsController controller = new UserCommentsController();
            var result = (HttpStatusCodeResult)controller.Edit((int?)null);
            Assert.AreEqual(400, result.StatusCode);
            Assert.IsInstanceOfType(result, typeof(HttpStatusCodeResult));

        }