Exemplo n.º 1
0
        public void TestWithImpersonationNotAuthorized()
        {
            _userService.Setup(mocked => mocked.GetByAuthenticationToken("123")).Returns(new MpUser
            {
                CanImpersonate = false
            });

            try
            {
                _fixture.WithImpersonation("123", "*****@*****.**", () => (_action.Object));
                Assert.Fail("Expected exception was not thrown");
            }
            catch (ImpersonationNotAllowedException e)
            {
                Assert.AreEqual("User is not authorized to impersonate other users.", e.Message);
            }
            _userService.VerifyAll();
            _action.VerifyAll();
            Assert.IsFalse(ImpersonatedUserGuid.HasValue());
        }