tests/WinDbgModule.tests.ps1

Describe "Basic Tests" {

    BeforeAll {

        Import-Module WinDbg
    
        $moduleRoot = (Get-Module WinDbg).ModuleBase
        Set-Location $moduleRoot\tests
        Add-Type -path .\TestApplication.cs -OutputAssembly .\TestApplication.exe
        $testApp = Start-Process .\TestApplication.exe -PassThru -WindowStyle Hidden
        Start-Sleep -m 100
    
        New-DbgSession -Id $testApp.Id
    
    }
    
    It "Ensures we can pipe heap objects into Get-DbgObject" {

        $testClass = Search-DbgHeap -Type TestClass
        $testObject = $testClass | Get-DbgObject.ps1
    
        $testClass.Address | Should not be $null
        $testClass.Address | Should be $testObject.Address
    
    }

    It "Tests basic properties and field lookups" {

        $testClass = Search-DbgHeap -Type TestClass
        $testObject = $testClass | Get-DbgObject.ps1

        $testObject.MyTestString | Should be "Hello World" "Should have got string field"
        $testObject.MyTestEnum | Should be 0 "Should have got unknown enum"
        $testObject.MyTestInt | Should be 10 "Should have got int property"
        $testObject.Path | Should be $testClass.Address "Should have start point for breadcrumb"
        $testObject.Type | Should be "WinDbgModule.TestClass" "Should have figurd out proper type"
        $testObject.Address | Should be $testClass.Address "Should have correct address"
   
    }

    AfterAll {

        Stop-DbgSession
        Remove-Module WinDbg
    
    }
}

## TODO: Value types that have a _value field in the reference
## TODO: Navigation
## TODO: Access fields property
## TODO: Static value types
## TODO: Arrays
## TODO: Get MSIL