Blog.Common.Web.Tests.Attributes.PreventCrossUserManipulationTest.ShouldThrowWhenNameIsEmptyInPrincipal C# (CSharp) Метод

ShouldThrowWhenNameIsEmptyInPrincipal() приватный Метод

private ShouldThrowWhenNameIsEmptyInPrincipal ( ) : void
Результат void
        public void ShouldThrowWhenNameIsEmptyInPrincipal()
        {
            _httpActionContext.ActionArguments.Add("dummy", new DummyObject { User = new User { Id = 1 } });
            _controller.ControllerContext.RequestContext.Principal = 
                new GenericPrincipal(new GenericIdentity("", ""), null);

            var attribute = new PreventCrossUserManipulationAttribute { UsersResource = _userResource.Object };
            var result = Assert.Throws<HttpResponseException>(() => attribute.OnActionExecuting(_httpActionContext));

            Assert.AreEqual(HttpStatusCode.InternalServerError, result.Response.StatusCode);
        }