'#define DEBUG
'#define TRACE

imports System
imports System.Diagnostics
imports Bugslayer

Public Module HappyAppy

    Sub Baz ( bAssert As Boolean )
        If ( True = bAssert )
            Debug.Assert ( False )
            Trace.Assert ( False )
        End If
    End Sub

    Sub Bar ( bAssert As Boolean )
        Baz ( bAssert )
    End Sub

    Sub Foo ( bAssert As Boolean )
        Bar ( bAssert )
    End Sub

    Sub Main ( )
        Debug.Listeners.Remove ( "Default" )

        Dim btl as BugslayerTraceListener

        btl = new BugslayerTraceListener ( )

        btl.Fail ( "Witaj!" )

        Debug.Listeners.Add ( btl )

        Foo ( true )

        Baz ( false )
        Baz ( true )
        Baz ( false )


        Debug.WriteLine ( btl , "WriteLine ( Object , String )" )
        Debug.WriteLine ( "WriteLine ( String )" )
        Debug.WriteLine ( btl )
        Debug.WriteLine ( "WriteLine " , "( String , String )" )

        btl.ShowEventLogTraces = true
        btl.EventSource = "MyLog"

        Debug.WriteLine ( btl , "WriteLine ( Object , String )" )
        Debug.WriteLine ( "WriteLine ( String )" )
        Debug.WriteLine ( btl )
        Debug.WriteLine ( "WriteLine " , "( String , String )" )

        Debug.Assert ( false )

        Console.WriteLine ( "Sprawdzenie czy klucz MyLog znajduje się w rejestrze" )
        Console.WriteLine ( "Wciśnij dowolny klawisz, aby go usunąć!" )
        Console.Read ( )
        btl.EventSource = Nothing
        BugslayerTraceListener.SafeEventLogDelete ( "MyLog" )

        Dim Switcher as BugslayerTraceSwitch

        Switcher = new BugslayerTraceSwitch ( "TestSwitch" , _
                                              "Mój testowy przełącznik" , _
                                              "Foo.txt" )
    End Sub

    Sub TestFunc ( Flag As Boolean )
        If ( true = Flag )
            Console.WriteLine ( "Wywołano TestFunc!" )
        Else
            Console.WriteLine ( "Wywołano TestFunc z fałszem!" )
        End If
    End Sub

End Module


