Created
April 2, 2019 08:07
-
-
Save shyassure/78fcb2e5a497d2d266f44f579e0c37d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MailAndSmsWarningSender | |
{ | |
internal class Options | |
{ | |
[Option("task")] | |
public string Task { get; set; } | |
} | |
public void ParseArgumentsAndRun(string[] args) | |
{ | |
try | |
{ | |
Parser.Default.ParseArguments<Options>(args) | |
.WithParsed(ExecuteTaskWithOptions) | |
.WithNotParsed(HandleParseError); | |
} | |
catch (Exception e) | |
{ | |
DisplayErrorMessage(e); | |
} | |
} | |
private void HandleParseError(IEnumerable<Error> errs) | |
{ | |
//This is never being run if using a test | |
throw new NotImplementedException(); | |
} | |
private void ExecuteTaskWithOptions(Options opts) | |
{ | |
Console.WriteLine("Executing"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestClass] | |
public class MailAndSmsWarningSenderTests | |
{ | |
private MailAndSmsWarningSender _sut; | |
[TestInitialize] | |
public void Setup() | |
{ | |
_sut = new MailAndSmsWarningSender(); | |
} | |
[TestMethod] | |
public void SendSmsOnWarning() | |
{ | |
_sut.ParseArgumentsAndRun(new []{"--task", "MailAndSmsWarningSender", "--test", "hejtest"}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment