コード例 #1
0
        public void TestUpdateRolePermission_ShouldUpdateRolePermissionWithIdButWithoutParameters()
        {
            var controller = new RolePermissionController();

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();
            controller.Request.Headers.Add("Authorization", "Bearer " + _accessToken);

            var item = UpdateRolePermission4();
            IHttpActionResult actionResult = controller.UpdateRolePermission(6, item);
            var negResult = actionResult as NegotiatedContentResult <string>;

            Assert.IsNotNull(negResult);
            Assert.AreEqual(HttpStatusCode.BadRequest, negResult.StatusCode);
        }
コード例 #2
0
        public void TestUpdateRolePermission_ShouldUpdateRolePermissionWithCorrectParameters()
        {
            var controller = new RolePermissionController();

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();
            controller.Request.Headers.Add("Authorization", "Bearer " + _accessToken);

            var item = UpdateRolePermission1();
            IHttpActionResult actionResult = controller.UpdateRolePermission(6, item);
            var negResult = actionResult as NegotiatedContentResult <string>;

            Assert.IsNotNull(negResult);
            Assert.AreEqual(HttpStatusCode.OK, negResult.StatusCode);
            Assert.AreEqual("RolePermission has been updated successfully.", negResult.Content);
            Assert.AreNotEqual("Content not found by Id =" + 6, negResult.Content);
        }