Public/Get-ConnectorSyncSessionOperationStatistics.tests.ps1

BeforeAll {
    $Script:Module = Import-Module "$($PSScriptRoot)/.." -Force -PassThru
}

Describe "Get-ConnectorSyncSessionOperationStatistics" {
    It "Should throw when unknown object passed in" {
        {
            @{ OperationType = "Unknown" } | Get-ConnectorSyncSessionOperationStatistics
        } | Should -Throw
    }

    It "Should not throw when valid object passed in" {
        {
            @{ OperationType = "Create" } | Get-ConnectorSyncSessionOperationStatistics
        } | Should -Not -Throw
    }

    It "Should report 0 for all operations when no operations passed in" {
        $Stats = @() | Get-ConnectorSyncSessionOperationStatistics
        $Stats.Create | Should -Be 0
        $Stats.Update | Should -Be 0
        $Stats.Delete | Should -Be 0
    }

    It "Should report correct counts for operations" {
        $Stats = @(
            @{ OperationType = "Create" }
            @{ OperationType = "Create" }
            @{ OperationType = "Update" }
            @{ OperationType = "Delete" }
            @{ OperationType = "Delete" }
            @{ OperationType = "Delete" }
        ) | Get-ConnectorSyncSessionOperationStatistics

        $Stats.Create | Should -Be 2
        $Stats.Update | Should -Be 1
        $Stats.Delete | Should -Be 3
    }
}