コード例 #1
0
        public void test_serialization()
        {
            ActionNoteRestore      foo = new ActionNoteRestore(Guid.NewGuid()), bar;
            DataContractSerializer fmt = new DataContractSerializer(typeof(ActionNoteRestore));

            using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) {
                fmt.WriteObject(ms, foo);
                ms.Seek(0, System.IO.SeekOrigin.Begin);
                System.Xml.XmlDictionaryReader xr = System.Xml.XmlDictionaryReader.CreateTextReader(ms, new System.Xml.XmlDictionaryReaderQuotas());
                bar = (ActionNoteRestore)(fmt.ReadObject(xr, true));
            }
            Assert.AreEqual(foo.guid, bar.guid);
        }
コード例 #2
0
        public void test_merge_to_remove_restore()
        {
            Guid               note_guid     = Guid.NewGuid();
            ActionNoteRemove   remove_action = new ActionNoteRemove(note_guid);
            List <EntryAction> actions       = new List <EntryAction>()
            {
                remove_action
            };

            ActionNoteRestore restore_action = new ActionNoteRestore(note_guid);

            restore_action.merge_to(actions);

            Assert.AreEqual(actions.Count, 0);
        }
コード例 #3
0
        public void test_revert()
        {
            Entry             ent       = new Entry(42, DateTime.Now, "Some Entry");
            Note              note      = new Note("Some note", ent.guid);
            CampaignState     state     = new CampaignState();
            Guid              note_guid = state.notes.add_note(note);
            ActionNoteRestore action    = new ActionNoteRestore(note_guid);

            state.notes.remove_note(note_guid);

            action.apply(state, ent);
            action.revert(state, ent);
            Assert.AreEqual(state.notes.notes.Count, 1);
            Assert.IsTrue(state.notes.notes.ContainsKey(note_guid));
            Assert.AreEqual(state.notes.notes[note_guid].contents, "Some note");
            Assert.AreEqual(state.notes.active_notes.Count, 0);
        }