How can we run a test method with multiple parameters in MSTest?

EDIT 4: Looks like this is completed in MSTest V2 June 17, 2016: https://blogs.msdn.microsoft.com/visualstudioalm/2016/06/17/taking-the-mstest-framework-forward-with-mstest-v2/ Original Answer: As of about a week ago in Visual Studio 2012 Update 1 something similar is now possible: [DataTestMethod] [DataRow(12,3,4)] [DataRow(12,2,6)] [DataRow(12,4,3)] public void DivideTest(int n, int d, int q) { Assert.AreEqual( q, n / d ); } EDIT: It … Read more

Unit Testing: DateTime.Now

The best strategy is to wrap the current time in an abstraction and inject that abstraction into the consumer. Alternatively, you can also define a time abstraction as an Ambient Context: public abstract class TimeProvider { private static TimeProvider current = DefaultTimeProvider.Instance; public static TimeProvider Current { get { return TimeProvider.current; } set { if … Read more

Unit testing private methods in C#

You can use the PrivateObject class: Class target = new Class(); PrivateObject obj = new PrivateObject(target); var retVal = obj.Invoke(“PrivateMethod”); Assert.AreEqual(expectedVal, retVal); Note: PrivateObject and PrivateType are not available for projects targeting netcoreapp2.0 – GitHub Issue 366