Esempio n. 1
0
        public void test_revert()
        {
            Entry            ent       = new Entry(42, DateTime.Now, "Some Entry");
            Task             task      = new Task(ent.guid, "Some task");
            Guid             task_guid = Guid.NewGuid();
            ActionTaskCreate action    = new ActionTaskCreate(task_guid, task);
            CampaignState    state     = new CampaignState();

            action.apply(state, ent);
            action.revert(state, ent);
            Assert.AreEqual(state.tasks.tasks.Count, 0);
            Assert.AreEqual(state.tasks.active_tasks.Count, 0);
        }
Esempio n. 2
0
        public void test_serialization()
        {
            Task                   task = new Task(Guid.NewGuid(), "Some task");
            ActionTaskCreate       foo = new ActionTaskCreate(Guid.NewGuid(), task), bar;
            DataContractSerializer fmt = new DataContractSerializer(typeof(ActionTaskCreate));

            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 = (ActionTaskCreate)(fmt.ReadObject(xr, true));
            }
            Assert.AreEqual(foo.guid, bar.guid);
            Assert.AreEqual(foo.task.name, bar.task.name);
        }
Esempio n. 3
0
        public void test_merge_to_remove_create()
        {
            Guid               task_guid     = Guid.NewGuid();
            ActionTaskRemove   remove_action = new ActionTaskRemove(task_guid);
            List <EntryAction> actions       = new List <EntryAction>()
            {
                remove_action
            };

            Task             task          = new Task(Guid.NewGuid(), "Some task");
            ActionTaskCreate create_action = new ActionTaskCreate(task_guid, task);

            create_action.merge_to(actions);

            Assert.AreEqual(actions.Count, 0);
        }
Esempio n. 4
0
        public void test_apply()
        {
            Entry            ent       = new Entry(42, DateTime.Now, "Some Entry");
            Task             task      = new Task(ent.guid, "Some task");
            Guid             task_guid = Guid.NewGuid();
            ActionTaskCreate action    = new ActionTaskCreate(task_guid, task);
            CampaignState    state     = new CampaignState();

            action.apply(state, ent);
            Assert.AreEqual(state.tasks.tasks.Count, 1);
            Assert.IsTrue(state.tasks.tasks.ContainsKey(task_guid));
            Assert.AreEqual(state.tasks.tasks[task_guid].name, "Some task");
            Assert.IsFalse(ReferenceEquals(state.tasks.tasks[task_guid], task));
            Assert.AreEqual(state.tasks.active_tasks.Count, 1);
            Assert.IsTrue(state.tasks.active_tasks.Contains(task_guid));
        }
Esempio n. 5
0
        public void test_merge_to_create_update()
        {
            Guid               task_guid = Guid.NewGuid();
            Task               from = new Task(Guid.NewGuid(), "Some task"), to = new Task(Guid.NewGuid(), "Some updated task");
            ActionTaskCreate   create_action = new ActionTaskCreate(task_guid, from);
            List <EntryAction> actions       = new List <EntryAction>()
            {
                create_action
            };

            ActionTaskUpdate update_action = new ActionTaskUpdate(task_guid, from, to, true, false, false, false, false);

            update_action.merge_to(actions);

            Assert.AreEqual(actions.Count, 1);
            ActionTaskCreate merged_action = actions[0] as ActionTaskCreate;

            Assert.IsNotNull(merged_action);
            Assert.AreEqual(merged_action.guid, task_guid);
            Assert.AreEqual(merged_action.task.entry_guid, from.entry_guid);
            Assert.AreEqual(merged_action.task.name, "Some updated task");
        }