New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unit test run button that you can point to a unit test class #256
Comments
Hi! Have a look at this issue #123 . Is this the kind of experience you are describing ? |
@philcarbone You can also accomplish something like this using our "regions" functionality. If you try the below example, the user gets a compilation error if they don't return a boolean, a success message if they Here's what the markdown file would contain (replace quote chars with backticks) Change your code to return a value. Specifically, you should return a true boolean.
'''cs --source-file ./Program.cs --project ./tutorial.csproj --region TestUserCode
''' And here's what Program.cs would contain: using System;
using System.Threading.Tasks;
namespace tutorial
{
public class Program
{
static int Main(
string region = null,
string session = null,
string package = null,
string project = null,
string[] args = null)
{
return region switch
{
"TestUserCode" => TestUserCode(),
_ => 0
};
}
public static int TestUserCode()
{
var result = UserCodeGoesHere();
if (result)
{
Console.WriteLine("Good job!");
}
else
{
Console.WriteLine("Try again :(");
}
return 0;
}
private static bool UserCodeGoesHere()
{
#region TestUserCode
#endregion
}
}
} |
Oh, and here's the contents of <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.2.0-alpha.19226.1" />
<PackageReference Include="System.CommandLine.Experimental" Version="0.2.0-alpha.19226.1" />
</ItemGroup>
</Project>
|
Is your feature request related to a problem? Please describe.
As a person teaching .NET, I would appriciate the ability to ask a question and have the user "try" something in C# to answer the question or fulfill the requirement, and get feedback (success or fail) and maybe a message.
Describe the solution you'd like
It would be nice to write unit tests against a class or method that could be used as a way to provide feedback to the learner. This would be a great way to make this a powerhouse learning/teaching tool.
Describe alternatives you've considered
None yet
(I apologize I wrote this on my phone. I will provide examples once I'm on a large screen again)
The text was updated successfully, but these errors were encountered: