public void UpdatesFrom1To2Correctly() { INoteRepositoryUpdater updater = new NoteRepositoryUpdater(); XDocument xml = XDocument.Parse(Version1Repository); bool result = updater.Update(xml); NoteRepositoryModel repository = XmlUtils.DeserializeFromXmlDocument <NoteRepositoryModel>(xml); Assert.IsTrue(result); Assert.IsNotNull(repository); Assert.AreEqual(new Guid("093b917a-f69f-4dd3-91b7-ad175fe0a4c1"), repository.Id); Assert.AreEqual(3, repository.Notes.Count); Assert.AreEqual(new Guid("a2b16ab9-9f7f-4389-916f-f2ef9a2f3a3a"), repository.Notes[0].Id); string noteContent = repository.Notes[0].HtmlContent; Assert.IsTrue(noteContent.Contains("<h1>Borrowed</h1>")); Assert.IsTrue(noteContent.Contains("<p>• 'The Black Magician Trilogy'")); Assert.AreEqual(new Guid("70a25de4-2141-4164-aefc-b9b2624a112c"), repository.Notes[1].Id); noteContent = repository.Notes[1].HtmlContent; Assert.IsFalse(noteContent.Contains("<h1>")); // no title Assert.IsTrue(noteContent.Contains("<p>- Milk")); noteContent = repository.Notes[2].HtmlContent; Assert.IsTrue(noteContent.Contains("<field>")); Assert.AreEqual(1, repository.DeletedNotes.Count); Assert.AreEqual(new Guid("fae40c63-d850-4b78-a8bd-609893d2983b"), repository.DeletedNotes[0]); Assert.AreEqual(NoteRepositoryModel.NewestSupportedRevision, repository.Revision); }
public void Update_SetsNewestVersionNumber() { // Set revision too small NoteRepositoryModel repository = new NoteRepositoryModel { Revision = NoteRepositoryModel.NewestSupportedRevision - 1 }; XDocument repositoryXml = XmlUtils.SerializeToXmlDocument(repository); INoteRepositoryUpdater updater = new NoteRepositoryUpdater(); Assert.IsTrue(updater.Update(repositoryXml)); Assert.AreEqual(NoteRepositoryModel.NewestSupportedRevision.ToString(), repositoryXml.Root.Attribute("revision").Value); }
public void IsTooNewForThisAppWorksCorrectly() { INoteRepositoryUpdater updater = new NoteRepositoryUpdater(); int supportedVersion = updater.NewestSupportedRevision; NoteRepositoryModel repository = new NoteRepositoryModel(); repository.Revision = supportedVersion - 1; XDocument repositoryXml = XmlUtils.SerializeToXmlDocument(repository); Assert.IsFalse(updater.IsTooNewForThisApp(repositoryXml)); repository.Revision = supportedVersion; repositoryXml = XmlUtils.SerializeToXmlDocument(repository); Assert.IsFalse(updater.IsTooNewForThisApp(repositoryXml)); repository.Revision = supportedVersion + 1; repositoryXml = XmlUtils.SerializeToXmlDocument(repository); Assert.IsTrue(updater.IsTooNewForThisApp(repositoryXml)); }
public void NewestSupportedVersionIsCorrect() { INoteRepositoryUpdater updater = new NoteRepositoryUpdater(); Assert.AreEqual(6, updater.NewestSupportedRevision); }