public void init() { papers = new PaperCollection(); papers.Title = "This is my data model"; papers.Papers = new List <Paper> (); // mock up some papers }
public void CanCreateAFile() { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream("dataModel.dat", FileMode.Create, isf)) { var serializer = new XmlSerializer(typeof(PaperCollection)); serializer.Serialize(stream, papers); } } // go get the file using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream("dataModel.dat", FileMode.OpenOrCreate, isf)) { Assert.True(stream.Length > 0, "should have a dataModel.dat file"); var serializer = new XmlSerializer(typeof(PaperCollection)); PaperCollection col = serializer.Deserialize(stream) as PaperCollection; Assert.NotNull(col, "collection should not be null"); Assert.That(col.Title == papers.Title, "titles should match"); } } }