Tests/Test-OriAzBopModuleComplete.tests.ps1

. $PSScriptRoot\..\Public\Get-OriAzBopFolderHash.ps1
. $PSScriptRoot\..\Public\Test-OriAzBopModuleComplete.ps1

Describe 'OriAzBopBoostrapOriPsgallery\Test-OriAzBopModuleComplete' {
    
  Context 'Succesfull excution of get hash Test is true' {   
    
    $testPath = "TestDrive:\test.txt"
    Set-Content $testPath -value "my test text."

    Mock -CommandName Get-OriAzBopFolderHash -Verifiable -MockWith {
      return "3a2525173780253134a12527003ae151"
    }

    Mock -CommandName Write-Verbose -Verifiable

    it 'Should be succesfully processed' {
        {
            $return = Test-OriAzBopModuleComplete `
            -Path "TestDrive:\test.txt" `
            -RequiredMd5 "3a2525173780253134a12527003ae151"

            $return | Should -BeExactly $true

        } | Should -Not -Throw
    }      
      
      Assert-MockCalled Write-Verbose -Times 1 -Exactly -ParameterFilter {
        $Message -eq "-- End of Test-OriAzBopModuleComplete --"
      }
       
      Assert-VerifiableMock
  
  }

  Context 'Succesfull excution of get hash Test is false' {   
    
    $testPath = "TestDrive:\test.txt"
    Set-Content $testPath -value "my test text."

    Mock -CommandName Get-OriAzBopFolderHash -Verifiable -MockWith {
      return "3a2525173780253134a12527003ae151"
    }

    Mock -CommandName Write-Verbose -Verifiable

    it 'Should be succesfully processed' {
        {
            $return = Test-OriAzBopModuleComplete `
            -Path "TestDrive:\test.txt" `
            -RequiredMd5 "4a2525173780253134a12527003ae151"

            $return | Should -BeExactly $false

        } | Should -Not -Throw
    }      
      
      Assert-MockCalled Write-Verbose -Times 1 -Exactly -ParameterFilter {
        $Message -eq "-- End of Test-OriAzBopModuleComplete --"
      }
       
      Assert-VerifiableMock
  
  }

}