public void MementoSerialTestCase()
        {
            var speedo = new SpeedometerSerial
            {
                CurrentSpeed = 50
            };
            speedo.CurrentSpeed = 100;
            //Log
            Console.WriteLine(@"Current speed: {0}",
                speedo.CurrentSpeed);

            //guardar el estado
            var memento = new SpeedometerMementoSerial(speedo);

            //cambiar el objeto
            speedo.CurrentSpeed = 180;
            //Log
            Console.WriteLine(@"Current speed: {0}",
                speedo.CurrentSpeed);

            // restarurar estado
            speedo = memento.RestoreState();

            Assert.AreEqual(100, speedo.CurrentSpeed);
        }
 public SpeedometerMementoSerial(SpeedometerSerial speedometer)
 {
     //Serial...
     var stream = File.Open(@"spidometer.ser", FileMode.Create);
     var formatter = new BinaryFormatter();
     formatter.Serialize(stream, speedometer);
     stream.Close();
 }