Fluctuation theorem of a mesoscopic engine and spin switching