0

I want to mock the value of Utils.IsLocalEnv to be false. How can I do it using C# in unit tests? I tried this: Utils.IsLocalEnv = () => true; but get wrong.

    public static class Utils
    {
        public static bool IsLocalEnv()
        {
            if (aspNetCoreEnv.ToLower() == "development")
            {
                return true;
            }

            return false;
        }
     }
susanna
  • 1,395
  • 3
  • 20
  • 32
  • 1
    side note : your method can be simplified to `return aspNetCoreEnv.ToLower() == "development";` – Cid Sep 09 '21 at 11:51
  • Some options: https://stackoverflow.com/questions/12580015/how-to-mock-static-methods-in-c-sharp-using-moq-framework – Felipe Oriani Sep 09 '21 at 11:54

0 Answers0