Star Trek: Voyager Season 2 Episode 3
Stardate: 48892.1. When the Doctor is activated during a Red Alert, he learns that the ship has been abandoned, and that only B’Elanna Torres and an injured Captain Janeway are left on board. Soon afterwards, Lt. Barclay appears and tells him that his entire time on Voyager is an elaborate simulation, and he’s really a holo-engineer by the name of Zimmerman on Jupiter station in the Alpha Quadrant, who has been trapped on a holodeck for six hours. If he does not destroy Voyager’s warp core and end the program soon he will die.