public void SaveAndReadTest() { Who recipient = new Who(); recipient.Email = "*****@*****.**"; recipient.Rel = Who.RelType.MESSAGE_TO; entry.Recipient = recipient; StringBuilder sb = new StringBuilder(); XmlWriter writer = new XmlTextWriter(new StringWriter(sb)); entry.SaveToXml(writer); writer.Close(); XmlDocument document = new XmlDocument(); document.LoadXml(sb.ToString()); EmailListRecipientEntry newEntry = new EmailListRecipientEntry(); foreach (XmlNode node in document.FirstChild.ChildNodes) { ExtensionElementEventArgs args = new ExtensionElementEventArgs(); args.ExtensionElement = node; args.Base = newEntry; newEntry.Parse(args, new AtomFeedParser()); } Assert.AreEqual(recipient.Email, newEntry.Recipient.Email, "Parsed entry should have same recipient as original entry"); }
: base() { Categories.Add(EMAILLIST_RECIPIENT_CATEGORY); this.AddExtension(new Who()); } /// <summary> /// Constructs a new EmailListRecipientEntry, using /// the specified email address to initialize the /// Recipient property. /// </summary> /// <param name="recipientAddress">the recipient's /// email address</param> public EmailListRecipientEntry(String recipientAddress)
public void TestConvertEventToFreeBusy() { ExchangeUser user = new ExchangeUser(); EventEntry googleAppsEvent = new EventEntry("title", "description", "location"); DateTimeRange coveredRange = new DateTimeRange(DateTime.MaxValue, DateTime.MinValue); List<DateTimeRange> busyTimes = new List<DateTimeRange>(); List<DateTimeRange> tentativeTimes = new List<DateTimeRange>(); DateTime startDate = new DateTime(2007, 07, 1, 10, 0, 0, DateTimeKind.Utc); DateTime endDate = new DateTime(2007, 07, 1, 11, 0, 0, DateTimeKind.Utc); When when = new When(startDate, endDate); user.Email = "*****@*****.**"; // Event w/o valid times set should be ignored. CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, DateTime.MaxValue); Assert.AreEqual(coveredRange.End, DateTime.MinValue); Assert.AreEqual(busyTimes.Count, 0); Assert.AreEqual(tentativeTimes.Count, 0); googleAppsEvent.Times.Add(when); // Event w/o explicit status should be treated as busy, since this is how the data // comes from the free busy projection CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(tentativeTimes.Count, 0); Assert.AreEqual(busyTimes.Count, 1); Assert.AreEqual(busyTimes[0].Start, startDate); Assert.AreEqual(busyTimes[0].End, endDate); busyTimes.Clear(); // Confirmed event w/o attendees should be treated as busy. googleAppsEvent.Status = EventEntry.EventStatus.CONFIRMED; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(tentativeTimes.Count, 0); Assert.AreEqual(busyTimes.Count, 1); Assert.AreEqual(busyTimes[0].Start, startDate); Assert.AreEqual(busyTimes[0].End, endDate); busyTimes.Clear(); // Cancelled event should be treated as free. googleAppsEvent.Status = EventEntry.EventStatus.CANCELED; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(tentativeTimes.Count, 0); Assert.AreEqual(busyTimes.Count, 0); // Tentative event w/o attendees should be treated as tentative. googleAppsEvent.Status = EventEntry.EventStatus.TENTATIVE; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(busyTimes.Count, 0); Assert.AreEqual(tentativeTimes.Count, 1); Assert.AreEqual(tentativeTimes[0].Start, startDate); Assert.AreEqual(tentativeTimes[0].End, endDate); tentativeTimes.Clear(); Who john = new Who(); googleAppsEvent.Participants.Add(john); john.Attendee_Status = new Who.AttendeeStatus(); john.Email = user.Email; googleAppsEvent.Status = EventEntry.EventStatus.CONFIRMED; // Busy event with attendee tentative should be treated as tentative. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_TENTATIVE; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(busyTimes.Count, 0); Assert.AreEqual(tentativeTimes.Count, 1); Assert.AreEqual(tentativeTimes[0].Start, startDate); Assert.AreEqual(tentativeTimes[0].End, endDate); tentativeTimes.Clear(); // Busy event with attendee invited should be treated as tentative. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_INVITED; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(busyTimes.Count, 0); Assert.AreEqual(tentativeTimes.Count, 1); Assert.AreEqual(tentativeTimes[0].Start, startDate); Assert.AreEqual(tentativeTimes[0].End, endDate); tentativeTimes.Clear(); // Busy event with attendee accepted should be treated as busy. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_ACCEPTED; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(tentativeTimes.Count, 0); Assert.AreEqual(busyTimes.Count, 1); Assert.AreEqual(busyTimes[0].Start, startDate); Assert.AreEqual(busyTimes[0].End, endDate); busyTimes.Clear(); // Busy event with attendee declined should be treated as free. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_DECLINED; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(tentativeTimes.Count, 0); Assert.AreEqual(busyTimes.Count, 0); googleAppsEvent.Status = EventEntry.EventStatus.TENTATIVE; // Tentative event with attendee tentative should be treated as tentative. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_TENTATIVE; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(busyTimes.Count, 0); Assert.AreEqual(tentativeTimes.Count, 1); Assert.AreEqual(tentativeTimes[0].Start, startDate); Assert.AreEqual(tentativeTimes[0].End, endDate); tentativeTimes.Clear(); // Tentative event with attendee invited should be treated as tentative. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_INVITED; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(busyTimes.Count, 0); Assert.AreEqual(tentativeTimes.Count, 1); Assert.AreEqual(tentativeTimes[0].Start, startDate); Assert.AreEqual(tentativeTimes[0].End, endDate); tentativeTimes.Clear(); // Tentative event with attendee accepted should be treated as tentative. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_ACCEPTED; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(busyTimes.Count, 0); Assert.AreEqual(tentativeTimes.Count, 1); Assert.AreEqual(tentativeTimes[0].Start, startDate); Assert.AreEqual(tentativeTimes[0].End, endDate); tentativeTimes.Clear(); // Tentative event with attendee declined should be treated as free. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_DECLINED; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(tentativeTimes.Count, 0); Assert.AreEqual(busyTimes.Count, 0); googleAppsEvent.Status = EventEntry.EventStatus.CANCELED; // Cancelled event with attendee tentative should be treated as free. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_TENTATIVE; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(tentativeTimes.Count, 0); Assert.AreEqual(busyTimes.Count, 0); // Cancelled event with attendee invited should be treated as free. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_INVITED; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(tentativeTimes.Count, 0); Assert.AreEqual(busyTimes.Count, 0); // Cancelled event with attendee accepted should be treated as free. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_ACCEPTED; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(tentativeTimes.Count, 0); Assert.AreEqual(busyTimes.Count, 0); // Cancelled event with attendee declined should be treated as free. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_DECLINED; CallConvertEventToFreeBusy(user, googleAppsEvent, coveredRange, busyTimes, tentativeTimes); Assert.AreEqual(coveredRange.Start, startDate); Assert.AreEqual(coveredRange.End, endDate); Assert.AreEqual(tentativeTimes.Count, 0); Assert.AreEqual(busyTimes.Count, 0); }
/// <summary>standard typed Contains method </summary> public bool Contains(Who value) { // If value is not of type AtomEntry, this will return false. return (List.Contains(value)); }
/// <summary>standard typed remove method </summary> public void Remove(Who value) { base.Remove(value); }
/// <summary>standard typed insert method </summary> public void Insert(int index, Who value) { base.Insert(index, value); }
/// <summary>standard typed indexOf method </summary> public int IndexOf(Who value) { return (List.IndexOf(value)); }
/// <summary>standard typed add method </summary> public int Add(Who value) { return base.Add(value); }
public void TestConvertParticipantStatus() { EventEntry googleAppsEvent = new EventEntry("title", "description", "location"); BusyStatus status = BusyStatus.Busy; ExchangeUser user = new ExchangeUser(); user.Email = "*****@*****.**"; // The user status with no participants should be busy, since this is how the data // comes from the free busy projection status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Busy); Who john = new Who(); googleAppsEvent.Participants.Add(john); john.Email = user.Email; // Attendee with no status should be converted to busy. status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Busy); john.Attendee_Status = new Who.AttendeeStatus(); // Accepted attendee should be converted to busy. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_ACCEPTED; status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Busy); // Declined attendee should be converted to free. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_DECLINED; status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Free); // Tentative attendee should be converted to tentative. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_TENTATIVE; status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Tentative); // Attendee who hasn't responded yet should be converted to free. john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_INVITED; status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Tentative); // Attendee with bogus status should be converted to buys. john.Attendee_Status.Value = "Abrakadabra"; status = ConversionsUtil.ConvertParticipantStatus(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Busy); }
public void SetEmailListTest() { Who recipient = new Who(); entry.Recipient = recipient; Assert.AreEqual(recipient, entry.Recipient, "Recipient should be updated after setting"); }
////////////////////////////////////////////////////////////////////// /// <summary>Parses an xml node to create a Where object.</summary> /// <param name="node">the node to parse node</param> /// <param name="parser">the xml parser to use if we need to dive deeper</param> /// <returns>the created Where object</returns> ////////////////////////////////////////////////////////////////////// public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser) { Tracing.TraceCall(); Who who = null; if (node != null) { object localname = node.LocalName; if (!localname.Equals(this.XmlName) || !node.NamespaceURI.Equals(this.XmlNameSpace)) { return null; } } who = new Who(); if (node != null) { if (node.Attributes != null) { if (node.Attributes[GDataParserNameTable.XmlAttributeRel] != null) { who.Rel = node.Attributes[GDataParserNameTable.XmlAttributeRel].Value; } if (node.Attributes[GDataParserNameTable.XmlAttributeValueString] != null) { who.valueString = node.Attributes[GDataParserNameTable.XmlAttributeValueString].Value; } if (node.Attributes[GDataParserNameTable.XmlAttributeEmail] != null) { who.email = node.Attributes[GDataParserNameTable.XmlAttributeEmail].Value; } } if (node.HasChildNodes) { XmlNode childNode = node.FirstChild; while (childNode != null) { if (childNode is XmlElement) { if (childNode.LocalName == GDataParserNameTable.XmlAttendeeTypeElement) { who.Attendee_Type = AttendeeType.parse(childNode); } else if (childNode.LocalName == GDataParserNameTable.XmlAttendeeStatusElement) { who.Attendee_Status = AttendeeStatus.parse(childNode); } else if (childNode.LocalName == GDataParserNameTable.XmlEntryLinkElement) { who.EntryLink = EntryLink.ParseEntryLink(childNode, parser); } } childNode = childNode.NextSibling; } } } return who; }
String FillPersonen (DataRow IwTRow, Google.GData.Extensions.ExtensionCollection<Who> WhoList ) { String EventIDString = IwTRow ["ID"].ToString (); DataTable FullPersonenZuTermine = WordUpWCFAccess.GetCommonDataSet ("Select * from FullPersonenZuTermine where TermineID = '" + EventIDString + "'").Tables ["FullPersonenZuTermine"]; if (FullPersonenZuTermine.Rows.Count == 0) { WhoList.Clear (); return String.Empty; } bool SomethingChanged = false; ExtensionCollection<Who> DeleteList = new ExtensionCollection<Who> (); foreach (Who Participant in WhoList) { String Rel = Participant.Rel; if (Rel == "http://schemas.google.com/g/2005#event.organizer") continue; String eMail = Participant.Email; DataRow [] ParticipantBase = FullPersonenZuTermine.Select ("eMail = '" + eMail + "'"); if (ParticipantBase.Length == 1) continue; DeleteList.Add (Participant); } foreach (Who ParticipantsToDelete in DeleteList) { WhoList.Remove (ParticipantsToDelete); SomethingChanged = true; } foreach (DataRow PersonenRow in FullPersonenZuTermine.Rows) { String eMail = PersonenRow ["eMail"].ToString (); String NameID = String.Empty; if (String.IsNullOrEmpty (PersonenRow ["PersonalPresentationLink"].ToString ())) NameID = PersonenRow ["VorName"].ToString (); else NameID = "<a href=\"" + PersonenRow ["PersonalPresentationLink"].ToString () + "\" target=\"_blank\">" + PersonenRow ["VorName"].ToString () + "</a>"; bool IsAvailable = false; foreach (Who Participant in WhoList) { String Rel = Participant.Rel; if (Rel == "http://schemas.google.com/g/2005#event.organizer") continue; String WhoeMail = Participant.Email; if (String.Compare(WhoeMail, eMail, StringComparison.CurrentCultureIgnoreCase) == 0) { Participant.ValueString = NameID; IsAvailable = true; break; } } if (IsAvailable == false) { Who NewParticipant = new Who (); NewParticipant.Email = eMail; NewParticipant.ValueString = NameID; NewParticipant.Rel = "http://schemas.google.com/g/2005#event.attendee"; WhoList.Add (NewParticipant); SomethingChanged = true; } } List<String> PersonenInvolved = new List<string> (); int LineBreakCounter = 0; foreach (Who Participant in WhoList) { String Rel = Participant.Rel; if (Rel == "http://schemas.google.com/g/2005#event.organizer") continue; String WhoeMail = Participant.Email; String WhoNameID = Participant.ValueString; if ((++LineBreakCounter % 5) == 0) PersonenInvolved.Add ("<br/>" + WhoNameID); else PersonenInvolved.Add (WhoNameID); } return "<h4>Teilnehmer</h4>" + String.Join (", ", PersonenInvolved) + "<Br/>"; }
private void _setEventEntryToCurrent() { // create the entry if needed if (_entry == null) { _entry = new EventEntry(); } // Set the title _entry.Title.Text = this.Title; // Set the contents _entry.Content.Content = this.Contents; // Set a location for the event. _entry.Locations.Clear(); _entry.Locations.Add(new Where() { ValueString = this.Location }); // Set the event time _entry.Times.Clear(); _entry.Times.Add(new When(this.StartTime, this.EndTime)); // reminders clear first so we can update it _entry.Reminders.Clear(); foreach (var item in Reminders) { var newReminder = new Reminder(); newReminder.Method = item.Type; newReminder.Minutes = item.Minutes; newReminder.Hours = item.Hours; newReminder.Days = item.Days; _entry.Reminders.Add(newReminder); } // participants clear first so we can update it _entry.Participants.Clear(); foreach (var item in Invitees) { var newInvitee = new Who(); newInvitee.Email = item.Email; newInvitee.ValueString = item.Name; _entry.Participants.Add(newInvitee); } }
////////////////////////////////////////////////////////////////////// /// <summary>Parses an xml node to create a Where object.</summary> /// <param name="node">the node to parse node</param> /// <param name="parser">the xml parser to use if we need to dive deeper</param> /// <returns>the created Where object</returns> ////////////////////////////////////////////////////////////////////// public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser) { Tracing.TraceCall(); Who who = null; if (node != null) { object localname = node.LocalName; if (localname.Equals(this.XmlName) == false || node.NamespaceURI.Equals(this.XmlNameSpace) == false) { return(null); } } who = new Who(); if (node != null) { if (node.Attributes != null) { if (node.Attributes[GDataParserNameTable.XmlAttributeRel] != null) { who.Rel = node.Attributes[GDataParserNameTable.XmlAttributeRel].Value; } if (node.Attributes[GDataParserNameTable.XmlAttributeValueString] != null) { who.valueString = node.Attributes[GDataParserNameTable.XmlAttributeValueString].Value; } if (node.Attributes[GDataParserNameTable.XmlAttributeEmail] != null) { who.email = node.Attributes[GDataParserNameTable.XmlAttributeEmail].Value; } } if (node.HasChildNodes) { XmlNode childNode = node.FirstChild; while (childNode != null) { if (childNode is XmlElement) { if (childNode.LocalName == GDataParserNameTable.XmlAttendeeTypeElement) { who.Attendee_Type = AttendeeType.parse(childNode); } else if (childNode.LocalName == GDataParserNameTable.XmlAttendeeStatusElement) { who.Attendee_Status = AttendeeStatus.parse(childNode); } else if (childNode.LocalName == GDataParserNameTable.XmlEntryLinkElement) { who.EntryLink = EntryLink.ParseEntryLink(childNode, parser); } } childNode = childNode.NextSibling; } } } return(who); }
public void TestGetUserStatusForEvent() { EventEntry googleAppsEvent = new EventEntry("title", "description", "location"); BusyStatus status = BusyStatus.Busy; ExchangeUser user = new ExchangeUser(); DateTime startDate = new DateTime(2007, 07, 1, 10, 0, 0, DateTimeKind.Utc); DateTime endDate = new DateTime(2007, 07, 1, 11, 0, 0, DateTimeKind.Utc); When when = new When(startDate, endDate); user.Email = "*****@*****.**"; // The user status with no event times should be free status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Free); googleAppsEvent.Times.Add(when); // The user status with no event status should be busy, since this is how the data // comes from the free busy projection status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Busy); // The user status for confirmed meeting with no participants should be busy googleAppsEvent.Status = EventEntry.EventStatus.CONFIRMED; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Busy); // The user status for cancelled meeting (with no participants) should be free googleAppsEvent.Status = EventEntry.EventStatus.CANCELED; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Free); // The user status for tentative meeting with no participants should be tentative googleAppsEvent.Status = EventEntry.EventStatus.TENTATIVE; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Tentative); // The user status for bogus meeting with no participants should be busy googleAppsEvent.Status = new EventEntry.EventStatus(); googleAppsEvent.Status.Value = "Abrakadabra"; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Busy); Who john = new Who(); googleAppsEvent.Participants.Add(john); john.Email = user.Email; // The user status for confirmed meeting with no participant status should be busy googleAppsEvent.Status = EventEntry.EventStatus.CONFIRMED; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Busy); // The user status for cancelled meeting (no participant status) should be free googleAppsEvent.Status = EventEntry.EventStatus.CANCELED; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Free); // The user status for tentative meeting with no participant status should be tentative googleAppsEvent.Status = EventEntry.EventStatus.TENTATIVE; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Tentative); // The user status for bogus meeting with no participant status should be busy googleAppsEvent.Status = new EventEntry.EventStatus(); googleAppsEvent.Status.Value = "Abrakadabra"; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Busy); john.Attendee_Status = new Who.AttendeeStatus(); // The user status for any meeting if he declined should be free john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_DECLINED; googleAppsEvent.Status = EventEntry.EventStatus.CONFIRMED; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Free); googleAppsEvent.Status = EventEntry.EventStatus.CANCELED; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Free); googleAppsEvent.Status = EventEntry.EventStatus.TENTATIVE; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Free); googleAppsEvent.Status = new EventEntry.EventStatus(); googleAppsEvent.Status.Value = "Abrakadabra"; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Free); john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_ACCEPTED; // The user status for confirmed meeting if he accepted should be busy googleAppsEvent.Status = EventEntry.EventStatus.CONFIRMED; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Busy); // The user status for cancelled meeting if he accepted should be free googleAppsEvent.Status = EventEntry.EventStatus.CANCELED; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Free); // The user status for tentative meeting if he accepted should be tentative googleAppsEvent.Status = EventEntry.EventStatus.TENTATIVE; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Tentative); // The user status for bogus meeting if he accepted should be busy googleAppsEvent.Status = new EventEntry.EventStatus(); googleAppsEvent.Status.Value = "Abrakadabra"; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Busy); john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_TENTATIVE; // The user status for confirmed meeting if he is tentative should be tentative googleAppsEvent.Status = EventEntry.EventStatus.CONFIRMED; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Tentative); // The user status for cancelled meeting if he is tentative should be free googleAppsEvent.Status = EventEntry.EventStatus.CANCELED; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Free); // The user status for tentative meeting if he is tentative should be tentative googleAppsEvent.Status = EventEntry.EventStatus.TENTATIVE; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Tentative); // The user status for bogus meeting if he is tentative should be tentative googleAppsEvent.Status = new EventEntry.EventStatus(); googleAppsEvent.Status.Value = "Abrakadabra"; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Tentative); john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_INVITED; // The user status for confirmed meeting if he did not respond should be tentative googleAppsEvent.Status = EventEntry.EventStatus.CONFIRMED; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Tentative); // The user status for cancelled meeting if he he did not respond should be free googleAppsEvent.Status = EventEntry.EventStatus.CANCELED; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Free); // The user status for tentative meeting if he did not respond should be tentative googleAppsEvent.Status = EventEntry.EventStatus.TENTATIVE; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Tentative); // The user status for bogus meeting if he he did not respond should be tentative googleAppsEvent.Status = new EventEntry.EventStatus(); googleAppsEvent.Status.Value = "Abrakadabra"; status = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); Assert.AreEqual(status, BusyStatus.Tentative); }
public void WriteSchedule(String title, String description, String location, List<String> guestEmail, DateTime startTime, DateTime endTime) { EventEntry entry = new EventEntry(title, description, location); When eventTime = new When(startTime, endTime); entry.Times.Add(eventTime); guestEmail.ForEach((mail) => { Who guest = new Who(); guest.Email = mail; guest.Rel = description; entry.Participants.Add(guest); }); Uri url = new Uri("https://www.google.com/calendar/feeds/" + this._gmailID + "/private/full"); AtomEntry result = _gCal.Insert(url, entry); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>creates a new, in memory atom entry</summary> /// <returns>the new AtomEntry </returns> ////////////////////////////////////////////////////////////////////// public static EventEntry CreateEventEntry(int iCount) { EventEntry entry = new EventEntry(); // some unicode chars Char[] chars = new Char[] { '\u0023', // # '\u0025', // % '\u03a0', // Pi '\u03a3', // Sigma '\u03d1', // beta }; // if unicode needs to be disabled for testing, just uncomment this line // chars = new Char[] { 'a', 'b', 'c', 'd', 'e'}; AtomPerson author = new AtomPerson(AtomPersonType.Author); author.Name = "John Doe" + chars[0] + chars[1] + chars[2] + chars[3]; author.Email = "*****@*****.**"; entry.Authors.Add(author); AtomCategory cat = new AtomCategory(); cat.Label = "Default"; cat.Term = "Default" + chars[4] + " Term"; entry.Categories.Add(cat); entry.Content.Content = "this is the default text entry"; entry.Published = new DateTime(2001, 11, 20, 22, 30, 0); entry.Title.Text = "This is a entry number: " + iCount; entry.Updated = DateTime.Now; When newTime = new When(); newTime.StartTime = DateTime.Today.AddDays(-3); newTime.EndTime = DateTime.Today.AddDays(1); entry.Times.Add(newTime); entry.Reminder = new Reminder(); entry.Reminder.Minutes = DEFAULT_REMINDER_TIME; Who someone = new Who(); someone.ValueString = "*****@*****.**"; Who.AttendeeStatus status = new Who.AttendeeStatus(); status.Value = "event.accepted"; someone.Attendee_Status = status; someone.Rel = "http://schemas.google.com/g/2005#event.organizer"; entry.Participants.Add(someone); Where newPlace = new Where(); newPlace.ValueString = "A really nice place"; entry.Locations.Add(newPlace); newPlace = new Where(); newPlace.ValueString = "Another really nice place"; newPlace.Rel = Where.RelType.EVENT_ALTERNATE; entry.Locations.Add(newPlace); return entry; }
public EventEntry CreateEvent(string title, DateTime date, AtomEntryCollection users) { EventEntry entry = new EventEntry(); entry.Title.Text = title; entry.Content.Content = title + "Content"; When eventTime = new When(date, date + new System.TimeSpan(0, 0, 30, 0)); entry.Times.Add(eventTime); foreach (AppsExtendedEntry user in users) { string member = user.getPropertyValueByName("memberId"); Who who = new Who(); who.Email = member; who.Rel = Who.RelType.EVENT_ATTENDEE; entry.Participants.Add(who); } Uri postUri = new Uri(string.Format(feedUrl, admin)); return calendar.Insert(postUri, entry); }