0
internal string GetFullUserName()
        {
            if (!string.IsNullOrEmpty(User.Identity.Name))
            {
                return ((ICorePrincipal)HttpContext.Current.User).CoreUser.FirstName + " " + ((ICorePrincipal)HttpContext.Current.User).CoreUser.LastName;
            }
            return null;
        }

when this method is called its always returning null values. how to mock it? i tried using httpcontext mocking but i am not sure why its not working

  • Do you mean you want to mock the method `GetFullUserName`? Moq requires it to be `virtual`. `internal` is ok if you follow https://stackoverflow.com/questions/2772621/how-to-mock-the-internal-method-of-a-class – Klaus Gütter Aug 26 '22 at 10:30
  • You should edit your question to add the test method itself, showing how you have tried to use Moq. – Charlie Aug 26 '22 at 14:52

0 Answers0