Пример #1
0
 public void TestGetCalendar()
 {
     Room r = new Room { Uri = new Uri(Path.Combine(Directory.GetCurrentDirectory(), "../../fixture/RES-PHAR-129.ics")), RoomNumber = "RES-PHAR-129" };
     r.Load(r.Uri);
     IICalendar cal = r.GetCalendar();
     Assert.AreEqual<string>("Classroom Renovation Project", cal.Events.First().Summary);
     Assert.AreNotEqual<string>("jhbdvyceri", cal.Events.First().Summary); //makes sure that any arbitrary string matches the summary
 }
Пример #2
0
 public void TestFreeBusyToString()
 {
     SystemTime.Now = () => new DateTime(2013, 8, 1, 1, 0, 0);
     Room r = new Room { Uri = new Uri(Path.Combine(Directory.GetCurrentDirectory(), "../../fixture/RES-PHAR-129.ics")), RoomNumber = "RES-PHAR-129" };
     r.Load(r.Uri);
     Assert.AreEqual("Busy for 2 hours, and 45 minutes", r.FreeBusyToString(new DateTime(2013, 8, 1, 10, 15, 0)).ToString());
     //This may be best said as "free for about 4 days, and 21 hours
     Assert.AreEqual("Free for 4 days, and 21 hours", r.FreeBusyToString(new DateTime(2013, 8, 1, 13, 15, 0)).ToString());
 }
Пример #3
0
        public void TestBusyTimesFromMinFuture()
        {
            SystemTime.Now = () => new DateTime(2013, 8, 1, 1, 0, 0);
            Room r = new Room { Uri = new Uri(Path.Combine(Directory.GetCurrentDirectory(), "../../fixture/RES-PHAR-129.ics")), RoomNumber = "RES-PHAR-129" };
            r.Load(r.Uri);
            SystemTime.Now = () => new DateTime(2013, 8, 8, 15, 0, 0);
            IEnumerable<SimpleEvent> busyTimes = r.BusyTimes(120);

            //Assert
            Assert.AreEqual(busyTimes.Count(), 1);
            Assert.AreEqual(busyTimes.FirstOrDefault().EventStart, new DateTime(2013, 8, 8, 15, 30, 0));
        }
Пример #4
0
        public void TestSimpleCache()
        {
            Room r = new Room { Uri = new Uri(Path.Combine(Directory.GetCurrentDirectory(), "../../fixture/RES-PHAR-129.ics")), RoomNumber = "RES-PHAR-129" };
            r.Load(r.Uri);

            List<SimpleEvent> se;

            SystemTime.Now = () => DateTime.Today; //without this line, this test fails if it runs after another test because of some weird bug
            se = r.CacheToSimple();
            Assert.AreEqual<int>(0, se.Count); //should evaluate to true after 9/4/2013 because that day is the last event in the fixture
            se.Clear();

            se = r.CacheToSimple(new DateTime(2013, 8, 8, 17, 0, 0));
            Assert.AreEqual<int>(2, se.Count);
            se.Clear();

            se = r.CacheToSimple(new DateTime(2013, 8, 26), new DateTime(2013, 9, 4));
            Assert.AreEqual<int>(5, se.Count);
            se.Clear();

            se = r.CacheToSimple(new DateTime(2013, 8, 1), 6);
            Assert.AreEqual<int>(2, se.Count);
        }