Question: Here is my component and test of the component: 

```
@Component({
  template: `
    <div>
      <input [(ngModel)]="kek" />
    </div>
  `
})
class MyComp {
  @Input() kek;
}

fdescribe('kek', () => {
  let component: MyComp;
  let fixture: ComponentFixture<MyComp>;
  let de: DebugElement;

  beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [MyComp],
      imports: [FormsModule]
    });
  });

  beforeEach(() => {
    fixture = TestBed.createComponent(MyComp);
    component = fixture.componentInstance;
    de = fixture.debugElement;

    fixture.detectChanges();
  });

  it('', () => {
    component.kek = '228';

    expect(de.query(By.css('input')).nativeElement.value).toBe('');

    fixture.detectChanges();

    expect(de.query(By.css('input')).nativeElement.value).toBe('228');
  });
});

```

Test is not passing. Why? I expect that when I changed Input of component (`kek`), value of input is changed. Why value is `’’`?

Probably, I check the value of the input incorrectly. How should I do this?

Answer: 
At first, the `Car car = new Car();` line as well as the `StringWriter writer...` line are obviously obsolete.

Secondly, you want to serialize a `List<Car>`, not simply a `Car`. So you have to create the `XmlSerializer` accordingly.

Third point: wrap the usage of the stream in a `using` statement, so it is cleanly closed after usage:

```
public static void SaveFileAuto(List<Car> cars)
{
    // create serializer for typeof(List<Car>) not typeof(Car)
    XmlSerializer ser = new XmlSerializer(typeof(List<Car>));

    using (FileStream str = new FileStream(@"car.xml", FileMode.Create))
        ser.Serialize(str, cars);
}

```

To load and deserialize the xml file again, you can also use the `XmlSerializer`:

```
XmlSerializer serializer = new XmlSerializer(typeof(List<Car>));

List<car> cars;
using(FileStream stream = new FileStream(@"car.xml", FileMode.Open))
    cars = (List<Car>)serializer.Deserialize(stream);

```
You can create the xml however you'd like. You are better off using the XmlSerializer. [Referenced From Here](https://social.msdn.microsoft.com/Forums/vstudio/en-US/19906c15-a186-4a0e-8d20-81d48a25ee06/how-to-create-xml-file-by-iterating-through-list?forum=csharpgeneral)

```
// Your Car Class
public class Car
{
    public string Producer{ get; set; }
    public string Colour{ get; set; }
    public int LicensePlate { get; set; }
    public int CarID { get; set; }
}

// The List<Car>
var cars= new List<Car>(){ 
    new Car() { Producer= "Ford", Colour= "Red", LicensePlate= 123},
    new Car() { Producer= "Chevy", Colour= "Green", LicensePlate= 333}       
    };

// Build the document
public static void SaveFileAuto(List<Car> cars)
{
  XDocument xdoc = new XDocument(
    new XDeclaration("1.0", "utf-8", "yes"),
        // This is the root of the document
        new XElement("Cars", 
        from car in cars
        select
            new XElement("Car", new XAttribute("ID", car.CarID),
            new XElement("Producer",car.Producer),
            new XElement("Colour", car.Colour),
            new XElement("LicensePlate", car.LicensePlate));

   // Write the document to the file system            
   xdoc.Save("C:/Working Directory/Cars.xml");
}

```