Dependencies/Pester/4.1.0/Functions/New-MockObject.ps1

function New-MockObject {
<#
.SYNOPSIS
This function instantiates a .NET object from a type.
 
.DESCRIPTION
Using the New-MockObject you can mock an object based on .NET type.
 
An .NET assembly for the particular type must be available in the system and loaded.
 
.PARAMETER Type
The .NET type to create an object based on.
 
.EXAMPLE
PS> $obj = New-MockObject -Type 'System.Diagnostics.Process'
PS> $obj.GetType().FullName
    System.Diagnostics.Process
#>


    param (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [type]$Type
    )

    [System.Runtime.Serialization.Formatterservices]::GetUninitializedObject($Type)

}