public function testOnlyUpdatesPermissionsIfTheyHaveChanged()
 {
     $userId = 987;
     $user = new User();
     $user->WithId($userId);
     $user->WithPermissions(array(1, 2, 3, 5));
     $user->ChangePermissions(array(2, 3, 4, 6));
     $deletePermissionsCommand1 = new DeleteUserResourcePermission($userId, 1);
     $deletePermissionsCommand2 = new DeleteUserResourcePermission($userId, 5);
     $addPermissionsCommand1 = new AddUserResourcePermission($userId, 4);
     $addPermissionsCommand2 = new AddUserResourcePermission($userId, 6);
     $repo = new UserRepository();
     $repo->Update($user);
     $deleteCommands = $this->db->GetCommandsOfType('DeleteUserResourcePermission');
     $insertCommands = $this->db->GetCommandsOfType('AddUserResourcePermission');
     $this->assertEquals(2, count($deleteCommands));
     $this->assertEquals(2, count($insertCommands));
     $this->assertTrue($this->db->ContainsCommand($deletePermissionsCommand1));
     $this->assertTrue($this->db->ContainsCommand($deletePermissionsCommand2));
     $this->assertTrue($this->db->ContainsCommand($addPermissionsCommand1));
     $this->assertTrue($this->db->ContainsCommand($addPermissionsCommand2));
 }