Hi all,
I am in the process of taking over a legacy system that contains a Console App project, which is run as a Scheduled Task on our production servers. It mainly produces daily and weekly reports, does some database maintenance, etc.
The "main" of the console app handles inputting the command line arguments and determining which of several different processes to execute. Something like
Module MainModule
Public Sub Main()
'--- Check if command line arguments were specified
Dim args() As String = Environment.GetCommandLineArgs()
If args.Length > 1 Then
ConsoleMain(args)
End If
End Sub
Public Sub ConsoleMain(ByVal args() As String)
Dim rc As New Coordinator(enableEmails_)
Try
Dim arg_ As String = args(1)
Dim success_ As Boolean = True
Select Case arg_.ToUpper()
Case TaskType.OrderIntegration
success_ = rc.OrderIntegration()
Case TaskType.Motivators
success_ = rc.MotivatorsCreateFile(New CustomerMotivatorsManager)
... repeat for each of the various "Task Types"
End Module
What my question is: - This being a Console App with a Main() and ConsoleMain(), I don't seem to have anything that I can access from a Test - i.e. the "Main" and "ConsoleMain" do not appear to be accessible. How can I unit-test something like this, to test the "if argument 'x' is passed, function 'y' is called"?
Thanks in advance,