using System; using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using TestCaseExtension; namespace TestCaseTesting { [TestCaseClass] public class SimpleTestCaseSources { // Static TestCaseSources can provide more dynamic test-case types [TestMethod] [TestCaseSource("ProductPropertySource")] [TestCaseSource("ProductMethodSource")] public void TestProductWithSources(int expected, int a, int b) { Assert.AreEqual(expected, a * b); } // Static Properties, Fields, and no-argument Methods can be used private static IEnumerable ProductPropertySource { get { yield return new TestCaseData(6, 2, 3); yield return new TestCaseData(15, 3, 5); yield return new TestCaseData(24, 6, 4); } } // The type must be compatible with IEnumerable private static IList ProductMethodSource() { return new[] { new TestCaseData(2, 2, 1), new TestCaseData(4, 2, 2), new TestCaseData(8, 4, 2) }; } } }