public void TestPrivates() { // Note how we test internal method with InternalsVisibleTo // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/assemblies-gac/friend-assemblies var po = new SomeBusinessLogicClass(); Assert.AreEqual(3, po.SomeInternalLogic(1, 2)); Assert.AreEqual(42, SomeBusinessLogicClass.SomeInternalStaticLogic()); }
public void DataDrivenTest(string valueAsString) { // Don't forget to set a breakpoint in this method and // watch how the test method is called multiple times. var objectToTest = new SomeBusinessLogicClass(); var number = Convert.ToInt32(valueAsString); Assert.AreEqual(number * number, objectToTest.Square(number)); }
/*[DataSource("System.Data.SqlServerCe.4.0", "Data Source=TestData.sdf;", "TestValues", DataAccessMethod.Sequential)] * [DeploymentItem("TestData.sdf")] * [TestMethod]*/ public void DataDrivenTest() { // Don't forget to set a breakpoint in this method and // inspect this.TestContext and watch how the test method // is called multiple times depending on the content // of the data source. var objectToTest = new SomeBusinessLogicClass(); var number = Convert.ToInt32(this.TestContext.DataRow["Value"]); Assert.AreEqual(number * number, objectToTest.Square(number)); }