Represents a root collection of model changes.
コード例 #1
0
ファイル: SerializationTests.cs プロジェクト: NMFCode/NMF
        public void SerializeElementCreation()
        {
            var toCreate = new Semaphore() { Id = 1 };
            var change = new ElementCreation(toCreate);
            var before = new ModelChangeCollection();
            before.Changes.Add(change);
            var after = Serialize(before, typeof(ElementCreation));

            // We can't use SerializeAndAssert, because ElementCreation.Equals
            // compares the Semaphores, which don't implement Equals.

            Assert.AreEqual(1, after.Changes.Count);
            Assert.IsInstanceOfType(after.Changes[0], typeof(ElementCreation));
            var afterChange = (ElementCreation)after.Changes[0];
            Assert.IsInstanceOfType(afterChange.Element, typeof(Semaphore));
            Assert.AreEqual(toCreate.Id, ((Semaphore)afterChange.Element).Id);
        }
コード例 #2
0
ファイル: SerializationTests.cs プロジェクト: NMFCode/NMF
        private ModelChangeCollection Serialize(ModelChangeCollection before, params Type[] additionalTypes)
        {
            var serializer = new XmiSerializer(additionalTypes);

            string xmi;
            using (var writer = new StringWriter())
            {
                serializer.Serialize(before, writer);
                xmi = writer.ToString();
            }

            using (var reader = new StringReader(xmi))
            {
                return serializer.Deserialize(reader) as ModelChangeCollection;
            }
        }
コード例 #3
0
ファイル: SerializationTests.cs プロジェクト: NMFCode/NMF
 private void SerializeAndAssert(IModelChange change)
 {
     var before = new ModelChangeCollection();
     before.Changes.Add(change);
     var after = Serialize(before, change.GetType());
     Assert.AreEqual(before, after);
 }