Context"Get last history for single database"{$results=Get-DbaBackupHistory-SqlInstance$script:instance1-Database$dbname-LastIt"Should be 4 backups returned"{$results.count|ShouldBe4}It"First backup should be a Full Backup"{$results[0].Type|Shouldbe"Full"}It"Duration should be meaningful"{($results[0].end-$results[0].start).TotalSeconds|ShouldBe$results[0].Duration.TotalSeconds}It"Last Backup Should be a log backup"{$results[-1].Type|ShouldBe"Log"}}

Context"Get last history for all databases"{$results=Get-DbaBackupHistory-SqlInstance$script:instance1It"Should be more than one database"{($results|Where-ObjectDatabase-match"master").Count|ShouldBeGreaterThan0}}

Context"LastFull should work with multiple databases"{$results=Get-DbaBackupHistory-SqlInstance$script:instance1-Database$dbname,master-lastfullIt"Should return 2 records"{$results.count|ShouldBe2}}

Context"Testing IncludeCopyOnly with Last"{$resultsCo=Get-DbaBackupHistory-SqlInstance$script:instance1-Last-IncludeCopyOnly-Database$dbnameIt"Should return just the CopyOnly Full Backup"{($resultsCo|Measure-Object).count|ShouldBe1}}

Context"Testing TotalSize regression test for #3517"{It"supports large numbers"{$historyObject=New-ObjectSqlcollaborative.Dbatools.Database.BackupHistory$server=connect-dbainstance$script:instance1$cast=$server.Query('select cast(1000000000000000 as numeric(20,0)) AS TotalSize')$historyObject.TotalSize=$cast.TotalSize($historyObject.TotalSize.Byte)|Should-Be1000000000000000}}}