public void TestConvertToSysTime()
        {
            long     ticksInMinute = (long)60 * 10000000;
            DateTime utc1601_1_1   = new DateTime(1601, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            DateTime rawNow        = DateTime.Now;
            DateTime now           = new DateTime(rawNow.Year,
                                                  rawNow.Month,
                                                  rawNow.Day,
                                                  rawNow.Hour,
                                                  rawNow.Minute,
                                                  0,
                                                  0,
                                                  rawNow.Kind);
            int prevSysTime = FreeBusyConverter.ConvertToSysTime(now) - 1;

            for (int i = 0; i < 60 * 24 * 368; i++)
            {
                DateTime future  = now.AddTicks(i * ticksInMinute);
                int      sysTime = FreeBusyConverter.ConvertToSysTime(future);
                DateTime check   = utc1601_1_1.AddTicks(sysTime * ticksInMinute);

                Assert.AreEqual(future, check);
                Assert.AreEqual(prevSysTime + 1, sysTime);

                prevSysTime++;
            }
        }
        /// <summary>
        /// Sync a users free busy information between Google Calendar and the
        /// SchedulePlus Public Folder store
        /// </summary>
        /// <param name="user">The user to synchronize</param>
        /// <param name="googleAppsFeed">The Google Calendar events for the user</param>
        /// <param name="exchangeGateway">The Exchange Gateway to use</param>
        /// <param name="window">The DateTimeRange to synchronize for</param>
        public void SyncUser(
            ExchangeUser user,
            EventFeed googleAppsFeed,
            ExchangeService exchangeGateway,
            DateTimeRange window)
        {
            if (_log.IsInfoEnabled)
            {
                _log.InfoFormat("Creating F/B message.  [User={0}]", user.Email);
                _log.DebugFormat("The feed time zone is {0}", googleAppsFeed.TimeZone.Value);
            }

            string userFreeBusyUrl = FreeBusyUrl.GenerateUrlFromDN(_exchangeServerUrl,
                                                                   user.LegacyExchangeDN);

            List <string> busyMonthValues      = new List <string>();
            List <string> busyBase64Data       = new List <string>();
            List <string> tentativeMonthValues = new List <string>();
            List <string> tentativeBase64Data  = new List <string>();

            ConvertEventsToFreeBusy(user,
                                    googleAppsFeed.Entries,
                                    window,
                                    busyMonthValues,
                                    busyBase64Data,
                                    tentativeMonthValues,
                                    tentativeBase64Data);



            string startDate = FreeBusyConverter.ConvertToSysTime(window.Start).ToString();
            string endDate   = FreeBusyConverter.ConvertToSysTime(window.End).ToString();

            exchangeGateway.FreeBusy.CreateFreeBusyMessage(userFreeBusyUrl,
                                                           user.FreeBusyCommonName,
                                                           busyMonthValues,
                                                           busyBase64Data,
                                                           tentativeMonthValues,
                                                           tentativeBase64Data,
                                                           startDate,
                                                           endDate);

            if (_log.IsInfoEnabled)
            {
                _log.Info("Free/Busy message with the right properties created successfully.");
            }
        }