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

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

private ShouldSuccessfullyGetUserIdInComplexObjectParameter ( ) : void
Результат void
        public void ShouldSuccessfullyGetUserIdInComplexObjectParameter()
        {
            var complexDummyObject = new DummyComplexObject
                                     {
                                         SomeValue = 1,
                                         DummyObject = new DummyObject
                                                       {
                                                           Name = "foobar",
                                                           User = new User
                                                                  {
                                                                      Id = 1
                                                                  }
                                                       }
                                     };

            _controller.ControllerContext.RequestContext.Principal =
                new GenericPrincipal(new GenericIdentity("foo", "bar"), new[] { "user" });
            _userResource.Setup(a => a.GetByUserName(It.IsAny<string>())).Returns(new User { Id = 1 });
            _httpActionContext.ActionArguments.Add("dummy", complexDummyObject);

            var attribute = new PreventCrossUserManipulationAttribute { UsersResource = _userResource.Object };

            Assert.DoesNotThrow(() => attribute.OnActionExecuting(_httpActionContext));
        }