Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8553827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:44:34+00:00 2026-06-11T14:44:34+00:00

I have class which calls a static class, the static class basically is wrapper

  • 0

I have class which calls a static class, the static class basically is wrapper for another class. I know i can’t mock/ioc static classes but can do this for the non-static class?

below is a sample of my code structure

namespace lib.CanModify
{
    public class Something
    {
        public void method()
        {
            var obj = lib.CanNotModify.StaticClass.DoSomething();


        }
    }

}
namespace lib.CanNotModify
{
    public static class StaticClass
    {
        public static Node DoSomething()
        {
            /*The class i want to mock!*/
            Node node = new Node(10);
            return node;

        }
    }
}

please advice a way to mock the node class via mstest

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:44:35+00:00Added an answer on June 11, 2026 at 2:44 pm

    the short answer is no!

    You cannot mock concrete implementations of classes. You can only create instances of classes, you can only mock interfaces or base classes. A mock pretends to be a concrete class by implementing the properties of the interface or base class using inheritance. basically creating a new concrete instance of the class on the fly.

    If you change your structure to:

    public class Node() : INode
    

    Then you could mock this:

    var moqNode = new Mock<INode>();
    

    (this is moq syntax btw)

    you would then need to change your variable to type INode

    INode node = new Node(10);
    

    and then you’d actually also need to inject your dependancy:

    public static Node DoSomething(INode node)
            {
    
                return node;
    
            }
    

    which would make a farce of the entire thing……?!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class (RInterfaceHL) that calls another class (JRIEngine) which provides native methods
I have a background worker which calls a function within a separate class. This
I have a method which calls for a classmethod of another class def get_interface_params_by_mac(self,
I have a class ( EAGLView ) which calls a member function of a
I'm new to learning JSPs and Servlets. I have a Java class which calls
I have class World which manages creation of object... After creation it calls afterCreation
I have a custom MVC PHP framework that has a router class, which calls
I have some classes(call it Class A) which I would like to unit test
Ok guys I basically have a class which takes in 3 strings through the
I have a large static list which is basically a lookup table, so I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.