Exemplo n.º 1
0
        public void GetEvent_Invalid()
        {
            setup();
            eventToEdit.EventItemID = 9999;

            Event actual = EventAccessor.GetEvent(eventToEdit.EventItemID.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Matt Lapka
        /// Created: 2015/01/31
        /// Retrieve a single Event object from the Data Access layer with an eventItemID
        /// </summary>
        /// <param name="eventItemID">The EventItemID to search for</param>
        /// <returns>The Event object whose ID matches the passed parameter</returns>
        public Event RetrieveEvent(string eventItemID)
        {
            var    now = DateTime.Now;
            double cacheExpirationTime = 5;

            try
            {
                if (DataCache._currentEventList == null)
                {
                    return(EventAccessor.GetEvent(eventItemID));
                }
                //check time. If less than 5 min, return event from cache
                if (now > DataCache._EventListTime.AddMinutes(cacheExpirationTime))
                {
                    //get event from DB
                    var currentEvent = EventAccessor.GetEvent(eventItemID);
                    return(currentEvent);
                }
                else
                {
                    //get event from cached list
                    var   list         = DataCache._currentEventList;
                    Event currentEvent = list.FirstOrDefault(e => e.EventItemID.ToString() == eventItemID);
                    if (currentEvent != null)
                    {
                        return(currentEvent);
                    }
                    throw new ApplicationException("Event not found.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public void GetEvent_Valid()
        {
            setup();

            string expected = eventToTest.EventItemName;

            EventAccessor.AddEvent(eventToTest);
            eventToEdit = getEventObjectID(list);

            Event actual = EventAccessor.GetEvent(eventToEdit.EventItemID.ToString());

            EventAccessor.DeleteEventTestItem(eventToTest);

            Assert.AreEqual(expected, actual.EventItemName);
        }