Exemplo n.º 1
0
        public void test_revert_topics_only()
        {
            Entry ent = new Entry(42, DateTime.Now, "Some Entry");
            Guid  topic1 = Guid.NewGuid(), topic2 = Guid.NewGuid(), topic3 = Guid.NewGuid();
            Dictionary <Guid, int> adjust_topics = new Dictionary <Guid, int>()
            {
                [topic2] = -2,
                [topic3] = 1,
            };
            Note note = new Note("Some note", ent.guid, new HashSet <Guid>()
            {
                topic1, topic2
            });
            CampaignState    state     = new CampaignState();
            Guid             note_guid = state.notes.add_note(note);
            ActionNoteUpdate action    = new ActionNoteUpdate(note_guid, null, null, adjust_topics);

            action.apply(state, ent);
            action.revert(state, ent);
            Assert.AreEqual(note.contents, "Some note");
            Assert.AreEqual(note.topics.Count, 2);
            Assert.IsTrue(note.topics.Contains(topic1));
            Assert.IsTrue(note.topics.Contains(topic2));
            Assert.AreEqual(note.topics.contents[topic2], 2);
        }
Exemplo n.º 2
0
        public void test_revert_contents_only()
        {
            Entry ent = new Entry(42, DateTime.Now, "Some Entry");
            Guid  topic1 = Guid.NewGuid(), topic2 = Guid.NewGuid();
            Note  note = new Note("Some note", ent.guid, new HashSet <Guid>()
            {
                topic1, topic2
            });
            CampaignState    state     = new CampaignState();
            Guid             note_guid = state.notes.add_note(note);
            ActionNoteUpdate action    = new ActionNoteUpdate(note_guid, "Some note", "New note", null);

            action.apply(state, ent);
            action.revert(state, ent);
            Assert.AreEqual(note.contents, "Some note");
            Assert.AreEqual(note.topics.Count, 2);
            Assert.IsTrue(note.topics.Contains(topic1));
            Assert.IsTrue(note.topics.Contains(topic2));
        }