testcaseattribute

NUnit TestCaseSource pass value to factory

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 13:16:51
问题 I'm using the NUnit 2.5.3 TestCaseSource attribute and creating a factory to generate my tests. Something like this: [Test, TestCaseSource(typeof(TestCaseFactories), "VariableString")] public void Does_Pass_Standard_Description_Tests(string text) { Item obj = new Item(); obj.Description = text; } My source is this: public static IEnumerable<TestCaseData> VariableString { get { yield return new TestCaseData(string.Empty).Throws(typeof(PreconditionException)) .SetName("Does_Reject_Empty_Text");