It"drops a user with no ownerships"{Remove-DbaDbUser$server-Databasetempdb-User$user.Name$db.Users[$user.Name]|ShouldBeNullOrEmpty}

It"drops a user with a schema of the same name, but no objects owned by the schema"{$schema=New-ObjectMicrosoft.SqlServer.Management.SMO.Schema($db,$user.Name)$schema.Owner=$user.Name$schema.Create()Remove-DbaDbUser$server-Databasetempdb-User$user.Name$db.Users[$user.Name]|ShouldBeNullOrEmpty}

It"does NOT drop a user that owns objects other than a schema"{$schema=New-ObjectMicrosoft.SqlServer.Management.SMO.Schema($db,$user.Name)$schema.Owner=$user.Name$schema.Create()$table=New-ObjectMicrosoft.SqlServer.Management.SMO.Table($db,"dbtoolsci_remove_dba_db_user",$user.Name)$col1=New-ObjectMicrosoft.SqlServer.Management.SMO.Column($table,"col1",[Microsoft.SqlServer.Management.SMO.DataType]::Int)$table.Columns.Add($col1)$table.Create()Remove-DbaDbUser$server-Databasetempdb-User$user.Name-WarningActionSilentlyContinue$db.Users[$user.Name]|ShouldBe$user}}}