示例#1
0
        public void test_serialization()
        {
            ActionNoteRemove       foo = new ActionNoteRemove(Guid.NewGuid()), bar;
            DataContractSerializer fmt = new DataContractSerializer(typeof(ActionNoteRemove));

            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 = (ActionNoteRemove)(fmt.ReadObject(xr, true));
            }
            Assert.AreEqual(foo.guid, bar.guid);
        }
示例#2
0
        public void test_apply()
        {
            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);
            ActionNoteRemove action    = new ActionNoteRemove(note_guid);

            action.apply(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);
        }
示例#3
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);
        }
示例#4
0
        public void test_merge_to_update_remove()
        {
            Guid               note_guid     = Guid.NewGuid();
            ActionNoteUpdate   update_action = new ActionNoteUpdate(note_guid, "Some note", "Some updated note", null);
            List <EntryAction> actions       = new List <EntryAction>()
            {
                update_action
            };

            ActionNoteRemove remove_action = new ActionNoteRemove(note_guid);

            remove_action.merge_to(actions);

            Assert.AreEqual(actions.Count, 1);
            Assert.IsTrue(ReferenceEquals(actions[0], remove_action));
        }
示例#5
0
        public void test_merge_to_create_remove()
        {
            Guid               note_guid     = Guid.NewGuid();
            Note               note          = new Note("Some note", Guid.NewGuid());
            ActionNoteCreate   create_action = new ActionNoteCreate(note_guid, note);
            List <EntryAction> actions       = new List <EntryAction>()
            {
                create_action
            };

            ActionNoteRemove remove_action = new ActionNoteRemove(note_guid);

            remove_action.merge_to(actions);

            Assert.AreEqual(actions.Count, 0);
        }