public void Q2_Passing_BoundaryValues(string name, string expected) { // capture console output var output = new StringWriter(); Console.SetOut(output); // setup console input var data = string.Join(Environment.NewLine, new[] { name }); Console.SetIn(new System.IO.StringReader(data)); // run the test Strings01.Question2(); Assert.Contains(expected, output.ToString()); }
[InlineData("29/02/2019", "2019 was not a leap year")] // is not leap year public void Q5_Passing_Ext_VeryStrict(string dob, string expected) { // capture console output var output = new StringWriter(); Console.SetOut(output); // setup console input var data = string.Join(Environment.NewLine, new[] { dob }); Console.SetIn(new System.IO.StringReader(data)); // run the test Strings01.Question5(); Assert.Contains(expected, output.ToString()); }