コード例 #1
0
ファイル: WishlistController.cs プロジェクト: yi90s/cReg
        [InlineData(1, 6, false)] //Non-Existent Entry
        public void removeCourseFromStudentWishlistTest(int sid, int cid, bool success)
        {
            //Arrange
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
            {
                new Claim("sid", sid.ToString())
            }));

            _controller.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext {
                    User = user
                }
            };

            var result = _controller.removeCourseFromStudentWishlist(cid);

            Assert.NotNull(result);
            if (success)
            {
                Assert.IsType <OkObjectResult>(result);
            }
            else
            {
                Assert.IsType <BadRequestObjectResult>(result);
            }
        }