public void FromPathByCreator()
        {
            // Prerequisites
            const string path = "test-result.xml";

            var serializer = new XmlSerializer(typeof(VehicleData));
            var vehicleA = new Vehicle
            {
                SpeedMax = 50,
                CurrentSpeed = 20
            };

            // Process
            serializer.Save<Vehicle, VehicleData>(vehicleA, path);
            Vehicle vehicleB = serializer.Instantiate<Vehicle, VehicleData>(path);

            // Test
            Assert.IsTrue(vehicleB.SpeedMax == vehicleA.SpeedMax);
        }
        public void FromPath()
        {
            // Prerequisites
            const string path = "test-result.xml";

            var serializer = new XmlSerializer(typeof(Passenger));
            var passengerA = new Passenger
            {
                Name = "John",
                Age = 20
            };

            // Process
            serializer.Save(passengerA, path);
            var passengerB = serializer.Instantiate<Passenger>(path);

            // Test
            Assert.IsTrue(passengerB.Name == passengerA.Name);
            Assert.IsTrue(passengerB.Age == passengerA.Age);
        }
        public void FromStream()
        {
            // Prerequisites
            var serializer = new XmlSerializer(typeof(Passenger));
            var passengerA = new Passenger
            {
                Name = "John",
                Age = 20
            };

            // Process
            var stringWriter = new StringWriter();
            serializer.Save(passengerA, stringWriter);

            var stringReader = new StringReader(stringWriter.ToString());
            var passengerB = serializer.Instantiate<Passenger>(stringReader);

            // Test
            Assert.IsTrue(passengerB.Name == passengerA.Name);
            Assert.IsTrue(passengerB.Age == passengerA.Age);
        }
        public void FromStreamByCreator()
        {
            // Prerequisites
            var serializer = new XmlSerializer(typeof(VehicleData));
            var vehicleA = new Vehicle
            {
                SpeedMax = 50,
                CurrentSpeed = 20
            };

            // Process
            var stringWriter = new StringWriter();
            serializer.Save<Vehicle, VehicleData>(vehicleA, stringWriter);

            var stringReader = new StringReader(stringWriter.ToString());
            Vehicle vehicleB = serializer.Instantiate<Vehicle, VehicleData>(stringReader);

            // Test
            Assert.IsTrue(vehicleB.SpeedMax == vehicleA.SpeedMax);
        }