public void GetUniqueIdTest() { DocumentDataModel model = new DocumentDataModel(); model.New(new Size(700, 1200), new Thickness(32, 32, 32, 32)); DocumentDataModelInvariant(model); Assert.AreEqual(DataModel.ModelState.Ready, model.State); // The first unique id should be auto_0: string firstUniqueId = model.GetUniqueId(); Assert.AreEqual("auto_0", firstUniqueId); Assert.AreSame(null, model.GetShapeById(firstUniqueId)); // Adding an id which almost looks like an auto-id does not change GetUniqueId. XElement shape = model.AddShape(new XElement("Test", new XAttribute("Id", "auto_not"))); Assert.AreEqual(firstUniqueId, model.GetUniqueId()); shape = model.AddShape(new XElement("Test", new XAttribute("Id", firstUniqueId))); Assert.AreSame(shape, model.GetShapeById(firstUniqueId)); // The second unique id should be auto_1: string secondUniqueId = model.GetUniqueId(); Assert.AreEqual("auto_1", secondUniqueId); Assert.AreSame(null, model.GetShapeById(secondUniqueId)); // Removing a shape should not cause the unique id to decrement. shape.Remove(); Assert.AreEqual(secondUniqueId, model.GetUniqueId()); DocumentDataModelInvariant(model); Assert.AreEqual(DataModel.ModelState.Ready, model.State); }