Пример #1
0
        public void OnActionExecuting_SetsCurrentAccountId(String identifier, Int64 accountId)
        {
            controller.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Returns(new Claim(ClaimTypes.NameIdentifier, identifier));

            controller.OnActionExecuting(null);

            Int64?actual   = controller.CurrentAccountId;
            Int64?expected = accountId;

            Assert.Equal(expected, actual);
        }
Пример #2
0
        public void OnActionExecuting_SetsAuthorization()
        {
            controller = Substitute.ForPartsOf <AController>();
            controller.ControllerContext.HttpContext = Substitute.For <HttpContext>();
            controller.HttpContext.RequestServices.GetService(typeof(IAuthorization)).Returns(Substitute.For <IAuthorization>());

            controller.OnActionExecuting(null);

            Object?expected = controller.HttpContext.RequestServices.GetRequiredService <IAuthorization>();
            Object?actual   = controller.Authorization;

            Assert.Same(expected, actual);
        }