NSubstitute works with whatever testing framework you are currently using. The examples from the NSubstitute website all use NUnit, but you can also use XUnit, MBUnit, MSTest, etc. To run the NSubstitute examples unmodified try the Getting Started Guide
on the NUnit website:
http://nunit.org/index.php?p=getStarted&r=2.6.1
If you are after more general information about automated testing in .NET you can try the links on the Microsoft ASP.NET/MVC page on Testing:
Member
82 Points
273 Posts
How to Invoke Test methods in NSubstitute
Oct 01, 2012 11:57 PM|Mayil_Gilli|LINK
Hi All,
I am using NSubstitute to test my functions in my application.
Now i have written the test methods for my functions. I dont no how to run this test methods.
Can anyone tell me as how to run the test methods?
For eg i have
public interface ICalculator {
int Add(int a, int b);
string Mode { get; set; }
}
and i have used test method
[Test]
public void MyTestMethod() {
var calculator = Substitute.For<ICalculator>();
calculator.Add(1, 2).Returns(3);
}
Now how can i run the above test method in c# application
thanks
Gilli
None
0 Points
1 Post
Re: How to Invoke Test methods in NSubstitute
Oct 02, 2012 07:49 AM|dtchepak|LINK
NSubstitute works with whatever testing framework you are currently using. The examples from the NSubstitute website all use NUnit, but you can also use XUnit, MBUnit, MSTest, etc. To run the NSubstitute examples unmodified try the Getting Started Guide on the NUnit website:
http://nunit.org/index.php?p=getStarted&r=2.6.1
If you are after more general information about automated testing in .NET you can try the links on the Microsoft ASP.NET/MVC page on Testing:
http://www.asp.net/mvc/overview/testing
Regards,
David
None
0 Points
1 Post
Re: How to Invoke Test methods in NSubstitute
Sep 15, 2015 08:26 AM|sdo|LINK
Assert.AreEqual(calculator.Add(1, 2), 3);
or
Assert.IsTrue(calculator.Add(1, 2).Return(3));
None
0 Points
1 Post
Re: How to Invoke Test methods in NSubstitute
Oct 07, 2015 08:34 AM|hrndeger|LINK
Assert.AreEqual(calculator.Add(1, 2), 3);