public void test_serialization() { ActionCalendarEventRemove foo = new ActionCalendarEventRemove(Guid.NewGuid()), bar; DataContractSerializer fmt = new DataContractSerializer(typeof(ActionCalendarEventRemove)); 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 = (ActionCalendarEventRemove)(fmt.ReadObject(xr, true)); } Assert.AreEqual(foo.guid, bar.guid); }
public void test_apply() { Entry ent = new Entry(42, DateTime.Now, "Some Entry"); CalendarEvent evt = new CalendarEvent(Guid.NewGuid(), 42, "Some event"); CampaignState state = new CampaignState(); Guid event_guid = state.events.add_event(evt); ActionCalendarEventRemove action = new ActionCalendarEventRemove(event_guid); action.apply(state, ent); Assert.AreEqual(state.events.events.Count, 1); Assert.IsTrue(state.events.events.ContainsKey(event_guid)); Assert.AreEqual(state.events.events[event_guid].name, "Some event"); Assert.AreEqual(state.events.active_events.Count, 0); }
public void test_merge_to_remove_restore() { Guid event_guid = Guid.NewGuid(); ActionCalendarEventRemove remove_action = new ActionCalendarEventRemove(event_guid); List <EntryAction> actions = new List <EntryAction>() { remove_action }; ActionCalendarEventRestore restore_action = new ActionCalendarEventRestore(event_guid); restore_action.merge_to(actions); Assert.AreEqual(actions.Count, 0); }
public void test_merge_to_remove_create() { Guid event_guid = Guid.NewGuid(); ActionCalendarEventRemove remove_action = new ActionCalendarEventRemove(event_guid); List <EntryAction> actions = new List <EntryAction>() { remove_action }; CalendarEvent evt = new CalendarEvent(Guid.NewGuid(), 42, "Some event"); ActionCalendarEventCreate create_action = new ActionCalendarEventCreate(event_guid, evt); create_action.merge_to(actions); Assert.AreEqual(actions.Count, 0); }
public void test_merge_to_update_remove() { Guid event_guid = Guid.NewGuid(); CalendarEvent from = new CalendarEvent(Guid.NewGuid(), 42, "Some event"), to = new CalendarEvent(Guid.NewGuid(), 42, "Some updated event"); ActionCalendarEventUpdate update_action = new ActionCalendarEventUpdate(event_guid, from, to, false, true, false, false); List <EntryAction> actions = new List <EntryAction>() { update_action }; ActionCalendarEventRemove remove_action = new ActionCalendarEventRemove(event_guid); remove_action.merge_to(actions); Assert.AreEqual(actions.Count, 1); Assert.IsTrue(ReferenceEquals(actions[0], remove_action)); }