Setup a complicated row test with nunit and TestCaseSource and TestCaseData -


For each relatively return value such as 2 or 4, I want to pass this value as the parameter of the unit test method . But I get an exception that the parameters are not correct. When I remove the countExpected parameter, then the unit test gets cured, I can not just emphasize countExpected ...

Is this scenario NUnit's Is it possible at all? [Test, TestCaseSource ("VisibleWeekDays")] Public Zero Test (DayOfWeek [] shown setup, Int Counted) {// ARRANGE // ACT // ASSERT Assert.That ( Period. Count), is.EqualTo (countExpected)); } Private Stable IEnumerable & lt; TestCaseData & gt; VisibleWeekDays Returns (yield yields new testsecondata (new dayoffice [] {dayoff vink)} returns (2); returns new testseadata (new dayoffice [] (day vioch, day, vic.monday)) returns (4 ); // more days ...}}

see explanation:

. Return
Expected result to return to the method, which should have a corresponding return type.

TestCaseData If you want to use .Returns () , you must write the test as the following:

  [test, test season source ("VisibleWeekDays")] Public Int Test (Deophieic [] Visible Dataset Setup) {// ARRANGE // ACT // Duration of the return of the ASST. Calculation ();}   

Update :
If you want to pass as expected value parameter, then you must give it as regular test case data. See examples: [test, test sezers (publications)] Public Zero Test (DayoffWeek [] Visual Widgets, Intimate Counting) { ... assign (that periods.Count (), Is.EqualTo (countExpected)); } Private Stable IEnumerable & lt; TestCaseData & gt; VisibleWeekDays (yield yields new test fordata (new dayoff [] (Day Week Week), 2) yield yields new testsection ([Dayof W.C. Sande, DayWeek, Monday], 4); // more days ...}}

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -