Search code examples
c#.netnunitmstest

MS Test equivalent to Nunits Substitue.For


I have seen the following code in a Nunit unit test

        var controllerDescriptor = Substitute.For<HttpControllerDescriptor>();

What is the equivalent code using MS Test?


Solution

  • The code snippet is for NSubstitute mocking framework and has nothing to do with NUnit unit testing framework.

    MS Test is also a testing framework and the shown code runs the same for Nunit or MS Test.

    [TestClass]
    public class MytestClass {
        [TestMethod]
        public void MyTest() {
            var controllerDescriptor = Substitute.For<HttpControllerDescriptor>();
    
            //...
        }    
    }