コード例 #1
0
        public void GetandSetMeetingTitleTest()
        {
            MeetingNode meeting0 = new MeetingNode("", mID, sTime, eTime, PID, Attendents);
            MeetingNode meeting  = new MeetingNode(mTitle, mID, sTime, eTime, PID, Attendents);

            //test empty
            String actualmTitle0 = meeting0.GetMeetingTitle();

            Assert.AreEqual("", actualmTitle0, "Actual meeting title not equal to empty");

            //test get
            String actualmTitle1 = meeting.GetMeetingTitle();

            Assert.AreEqual(mTitle, actualmTitle1, "Actual meeting title not equal to mTitle");

            //test set string
            meeting.SetMeetingTitle("ECON 201");
            String actualmTitle2 = meeting.GetMeetingTitle();

            Assert.AreEqual("ECON 201", actualmTitle2, "Actual meeting title not equal to new mTitle");

            //test set int
            meeting.SetMeetingTitle(201);
            String actualmTitle3 = meeting.GetMeetingTitle();

            Assert.AreEqual("201", actualmTitle3, "Actual meeting title not equal to new mTitle 201");
        }
コード例 #2
0
        public void GetandSetMeetingID()
        {
            MeetingNode meeting0 = new MeetingNode(mTitle, "", sTime, eTime, PID, Attendents);
            MeetingNode meeting  = new MeetingNode(mTitle, mID, sTime, eTime, PID, Attendents);

            //test empty
            String actualmID0 = meeting0.GetMeetingID();

            Assert.AreEqual("", actualmID0, "Actual meeting ID not equal to empty");

            //test get
            String actualmID1 = meeting.GetMeetingID();

            Assert.AreEqual(mID, actualmID1, "Actual meeting ID not equal to mID");

            //test set string
            meeting.SetMeetingID("05_2");
            String actualmID2 = meeting.GetMeetingID();

            Assert.AreEqual("05_2", actualmID2, "Actual meeting ID not equal to 05_2");

            //test set int
            meeting.SetMeetingID(52);
            String actualmID3 = meeting.GetMeetingID();

            Assert.AreEqual("52", actualmID3, "Actual meeting ID not equal to 52");
        }
コード例 #3
0
        public void GetandSetParentIDTest()
        {
            MeetingNode meeting0 = new MeetingNode(mTitle, mID, sTime, eTime, "", Attendents);
            MeetingNode meeting  = new MeetingNode(mTitle, mID, sTime, eTime, PID, Attendents);

            //test empty
            String actualPID0 = meeting0.GetParentID();

            Assert.AreEqual("", actualPID0, "Actual Parent ID not equal to empty");

            //test get
            String actualPID1 = meeting.GetParentID();

            Assert.AreEqual(PID, actualPID1, "Actual meeting ID not equal to PID");

            //test set string
            meeting.SetParentID("01");
            String actualPID2 = meeting.GetParentID();

            Assert.AreEqual("01", actualPID2, "Actual meeting ID not equal to 01");

            //test set int
            meeting.SetParentID(1);
            String actualPID3 = meeting.GetParentID();

            Assert.AreEqual("1", actualPID3, "Actual meeting ID not equal to 1");
        }
コード例 #4
0
        public void ProcessTest()
        {
            File.Delete("Settings.xml");
            File.Delete("meetings.xml");
            File.Delete("files.xml");
            MeetingNode node = new MeetingNode();

            node.SetStartTime("2017/01/01 12:00:00");
            node.SetEndTime("2017/12/12 12:00:00");
            node.SetMeetingID("12345");
            node.SetMeetingTitle("Hello");
            FileNode file1 = new FileNode();
            FileNode file2 = new FileNode();

            file1.SetCreatedTime("2017/03/03 12:00:00");
            file1.SetFileName("test1");
            file2.SetCreatedTime("2016/03/03 12:00:00");
            file1.SetFileName("test2");
            LinkedList <FileNode> fn = new LinkedList <FileNode>();

            fn.AddLast(file1);
            fn.AddLast(file2);
            XMLProcessor processor = new XMLProcessor();

            processor.FirstUse();
            processor.SetFileList(fn);
            processor.ProcessFileWithMeetingNode(node);
            processor.Write();
        }
コード例 #5
0
        public void FirstUseAndWriteMeetingsTest()
        {
            File.Delete("meetings.xml");
            File.Delete("files.xml");
            Assert.IsTrue(test.FirstUse());
            //test empty input string for write meetings
            LinkedList <MeetingNode> list1 = new LinkedList <MeetingNode>();

            test.WriteMeetings(list1);
            Assert.IsTrue(!test.FirstUse());
            DateTime    testTimeS1 = new DateTime(2017, 4, 17, 14, 30, 20);
            DateTime    testTimeE1 = new DateTime(2017, 4, 17, 14, 35, 40);
            MeetingNode n          = new MeetingNode("TestMeeting1", "1", testTimeS1, testTimeE1, "", "Eddie,Anna");

            n.SetFiles("2");
            list1.AddLast(n);
            test.WriteMeetings(list1);
            Assert.IsTrue(!test.FirstUse());
            LinkedList <MeetingNode> list2 = new LinkedList <MeetingNode>();
            MeetingNode n2 = new MeetingNode("TestMeeting2", "2", testTimeS1, testTimeE1, "1", "Eddie,Anna,Lee");

            n2.SetFiles("1");
            list2.AddLast(n2);
            test.WriteMeetings(list2);
            Assert.IsTrue(!test.FirstUse());

            /*
             * File.Delete("meetings.xml");
             * Assert.IsTrue(test.FirstUse());
             * test.WriteMeetings(list2);
             * Assert.IsTrue(!test.FirstUse());
             */
        }
コード例 #6
0
        public void GetandSetStartTimeTest()
        {
            MeetingNode meeting0 = new MeetingNode(mTitle, mID, "0001/01/01 00:00:00", eTime, PID, Attendents);
            MeetingNode meeting  = new MeetingNode(mTitle, mID, sTime, eTime, PID, Attendents);

            //test empty
            String actualsTime0 = meeting0.GetStartTimeS();

            Assert.AreEqual("", actualsTime0, "Actual meeting start time does not equal to the minimized value");

            //test get
            String actualsTime1 = meeting.GetStartTimeS();

            Assert.AreEqual(sTime, actualsTime1, "Actual meeting start time does not equal to 2017/04/01 17:30:05");

            //test set
            meeting.SetStartTime("2017/04/02 12:30:00");
            String actualsTime2 = meeting.GetStartTimeS();

            Assert.AreEqual("2017/04/02 12:30:00", actualsTime2, "Actual meeting start time does not equal to 2017/04/02 12:30:00");
        }
コード例 #7
0
        public void GetandSetAttendentsTest()
        {
            MeetingNode meeting0 = new MeetingNode(mTitle, mID, sTime, eTime, PID, "");
            MeetingNode meeting  = new MeetingNode(mTitle, mID, sTime, eTime, PID, Attendents);

            //test empty
            String actualAttend0 = meeting0.GetAttendents();

            Assert.AreEqual("", actualAttend0, "Actual Attendents are not empty");

            //test get
            String actualAttend1 = meeting.GetAttendents();

            Assert.AreEqual(Attendents, actualAttend1, "Actual attendents are not Steven, Eddie, Xiaoying");

            //test set
            meeting.SetAttendents("Harris, John");
            String actualAttend2 = meeting.GetAttendents();

            Assert.AreEqual("Harris, John", actualAttend2, "Actual attendents are not Harris, John");
        }
コード例 #8
0
        public void GetandSetEndTimeTest()
        {
            MeetingNode meeting0 = new MeetingNode(mTitle, mID, sTime, "0001/01/01 00:00:00", PID, Attendents);
            MeetingNode meeting  = new MeetingNode(mTitle, mID, sTime, eTime, PID, Attendents);

            //test empty
            String actualsTime0 = meeting0.GetEndTimeS();

            Assert.AreEqual("", actualsTime0, "Actual meeting end time does not equal to empty, Actual:" + actualsTime0);

            //test get
            String actualsTime1 = meeting.GetEndTimeS();

            Assert.AreEqual(eTime, actualsTime1, "Expected: " + eTime + "Actual: " + actualsTime1);

            //test set
            meeting.SetEndTime("2017/04/02 18:00:30");
            String actualsTime2 = meeting.GetEndTimeS();

            Assert.AreEqual("2017/04/02 18:00:30", actualsTime2, "Actual meeting end time does not equal to 2017/04/02 18:00:30");
        }
コード例 #9
0
        public void SetFilesTest()
        {
            MeetingNode meeting = new MeetingNode(mTitle, mID, sTime, eTime, PID, Attendents);

            //test empty
            meeting.SetFiles("");
            String actualFileList0 = meeting.GetFileListS();

            Assert.AreEqual("", actualFileList0, "The actual file list is not empty");

            //test set single element
            meeting.SetFiles("1");
            String actualFileList1 = meeting.GetFileListS();

            Assert.AreEqual("1", actualFileList1, "The actual file list does not contain 1");

            //test set multiple element
            meeting.SetFiles("2;3;4");
            String actualFileList2 = meeting.GetFileListS();

            Assert.AreEqual(3, meeting.FileList.Count, "The actual file list does not contain 3 elements");
            Assert.AreEqual("2;3;4", actualFileList2, "The actual file list does not contain 2;3;4");
        }
コード例 #10
0
        public void GetDurationTest()
        {
            MeetingNode meeting0 = new MeetingNode(mTitle, mID, "0001/01/01 00:00:00", "0001/01/01 00:00:00", PID, Attendents);
            MeetingNode meeting  = new MeetingNode(mTitle, mID, sTime, eTime, PID, Attendents);

            //test empty
            TimeSpan expectedspan0 = new TimeSpan(0, 0, 0, 0);
            TimeSpan actualspan0   = meeting0.GetDuration();

            Assert.AreEqual(expectedspan0, actualspan0, "Actual duration does not equal to empty");

            //test get less than 1 day
            TimeSpan expectedspan1 = new TimeSpan(0, 1, 40, 0);
            TimeSpan actualspan1   = meeting.GetDuration();

            Assert.AreEqual(expectedspan1, actualspan1, "Actual duration does not equal to 0 day 1 hour 40 mins 0 second");

            //test get more than 1 day
            MeetingNode meeting2      = new MeetingNode(mTitle, mID, "2017/04/02 14:00:00", "2017/4/3 19:30:00", PID, Attendents);
            TimeSpan    expectedspan2 = new TimeSpan(1, 5, 30, 0);
            TimeSpan    actualspan2   = meeting2.GetDuration();

            Assert.AreEqual(expectedspan2, actualspan2, "Actual duration does not equal to 1 day 5 hour 30 mins 0 second");
        }
コード例 #11
0
        public void GetandAddFileListTest()
        {
            MeetingNode meeting0 = new MeetingNode(mTitle, mID, sTime, eTime, PID, Attendents);
            MeetingNode meeting  = new MeetingNode(mTitle, mID, sTime, eTime, PID, Attendents);

            //test get 0 GetFileList
            meeting0.AddFiles(0);
            LinkedList <Int32> actualFileList0   = meeting0.GetFileList();
            LinkedList <Int32> expectedFileList0 = new LinkedList <Int32>();

            expectedFileList0.AddLast(0);
            Assert.AreEqual(expectedFileList0.Last.Value, actualFileList0.Last.Value, "Actual FileList does not contain 0, Expected: {0}, Actual: {0}.", expectedFileList0.Last, actualFileList0.Last);

            //test get 0 GetFileListS
            String             acutualFileID01    = meeting0.GetFileListS();
            LinkedList <Int32> expectedFileList01 = new LinkedList <Int32>();

            expectedFileList01.AddFirst(0);
            String expectedFileID01 = expectedFileList01.First.Value.ToString();

            Assert.AreEqual(expectedFileID01, acutualFileID01, "Actual First FileID does not equal to 0, Expected: " + expectedFileID01 + " Actual: " + acutualFileID01);

            //test get GetFileList
            meeting.AddFiles(1);
            LinkedList <Int32> actualFileList2   = meeting.GetFileList();
            LinkedList <Int32> expectedFileList2 = new LinkedList <Int32>();

            expectedFileList2.AddFirst(1);
            Assert.AreEqual(expectedFileList2.First.Value, actualFileList2.First.Value, "Actual FileList does not contain 1");

            //test get GetFileListS
            String             acutualFileID02    = meeting.GetFileListS();
            LinkedList <Int32> expectedFileList02 = new LinkedList <Int32>();

            expectedFileList02.AddFirst(1);
            String expectedFileID02 = expectedFileList02.First.Value.ToString();

            Assert.AreEqual(expectedFileID02, acutualFileID02, "Actual First FileID does not equal to 1");

            //test add Filelist
            meeting.AddFiles(2);
            meeting.AddFiles(3);
            LinkedList <Int32> actualFileList3   = meeting.GetFileList();
            LinkedList <Int32> expectedFileList3 = new LinkedList <Int32>();

            expectedFileList3.AddLast(1);
            expectedFileList3.AddLast(2);
            expectedFileList3.AddLast(3);
            for (int n = 0; n < actualFileList3.Count; n++)
            {
                if (n == 0)
                {
                    Assert.AreEqual(expectedFileList3.First.Value, actualFileList3.First.Value, "1st element in two lists are not equal");
                }
                if (n == 1)
                {
                    Assert.AreEqual(expectedFileList3.First.Next.Value, actualFileList3.First.Next.Value, "2nd element in two lists are not equal");
                }
                if (n == 2)
                {
                    Assert.AreEqual(expectedFileList3.First.Next.Next.Value, actualFileList3.First.Next.Next.Value, "3rd element in two lists are not equal");
                }
            }

            //test set Filelist
            meeting0.FileList.Clear();
            meeting0.SetFiles("1;2;3");
            LinkedList <Int32> actualFileList4   = meeting0.GetFileList();
            LinkedList <Int32> expectedFileList4 = new LinkedList <Int32>();

            expectedFileList4.AddLast(1);
            expectedFileList4.AddLast(2);
            expectedFileList4.AddLast(3);
            for (int n = 0; n < actualFileList4.Count; n++)
            {
                if (n == 0)
                {
                    Assert.AreEqual(expectedFileList4.First.Value, actualFileList4.First.Value, "1st element in two lists are not equal");
                }
                if (n == 1)
                {
                    Assert.AreEqual(expectedFileList4.First.Next.Value, actualFileList4.First.Next.Value, "2nd element in two lists are not equal");
                }
                if (n == 2)
                {
                    Assert.AreEqual(expectedFileList4.First.Next.Next.Value, actualFileList4.First.Next.Next.Value, "3rd element in two lists are not equal");
                }
            }
        }
コード例 #12
0
ファイル: App.xaml.cs プロジェクト: Zezephyrphyr/ProjectKIKI
        public static void fetchFromGoogle(DateTime minTime)
        {
            Debug.Print("" + minTime);
            MeetingNode meeting = new MeetingNode();
            FileNode    file    = new FileNode();

            // Create Google Calendar API service.
            var service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = ApplicationName,
            });

            // Define parameters of request.
            EventsResource.ListRequest request = service.Events.List("primary");
            request.TimeMin      = minTime;
            request.TimeMax      = DateTime.Now;
            request.ShowDeleted  = false;
            request.SingleEvents = true;


            // List events.
            try
            {
                Events events = request.Execute();
                if (events.Items != null && events.Items.Count > 0)
                {
                    foreach (var eventItem in events.Items)
                    {
                        meeting = new MeetingNode();
                        string attendee = "";
                        string when     = eventItem.Start.DateTime.ToString();
                        if (eventItem.Attendees != null)
                        {
                            EventAttendee[] attendeeData = new EventAttendee[eventItem.Attendees.Count];
                            eventItem.Attendees.CopyTo(attendeeData, 0);
                            List <String> attendeelist = new List <String>();
                            for (int i = 0; i < eventItem.Attendees.Count; i++)
                            {
                                if ((attendeeData[i].DisplayName != null) && (attendeeData[i].DisplayName != ""))
                                {
                                    attendeelist.Add(attendeeData[i].DisplayName);
                                }
                            }
                            if (attendeelist.Count >= 2)
                            {
                                for (int i = 0; i < attendeelist.Count; i++)
                                {
                                    attendee = attendee + attendeelist[i];
                                    if (i != attendeelist.Count - 1)
                                    {
                                        attendee = attendee + ";";
                                    }
                                }
                            }
                            else
                            {
                                attendee = "N/A";
                            }
                        }
                        else
                        {
                            attendee = "N/A";
                        }

                        meeting.SetAttendents(attendee);
                        meeting.SetMeetingID(eventItem.Id);
                        meeting.SetParentID(eventItem.ICalUID.ToString());
                        meeting.SetStartTime(when);
                        meeting.SetEndTime(eventItem.End.DateTime.ToString());
                        meeting.SetMeetingTitle(eventItem.Summary);
                        if (DateTime.Compare(meeting.GetEndTime(), DateTime.Now) <= 0)
                        {
                            meetingList.AddLast(meeting);
                        }
                        if (eventItem.Attachments != null)
                        {
                            for (int i = 0; i < eventItem.Attachments.Count; i++)
                            {
                                file = new FileNode();
                                file.SetModifiedTime(eventItem.Start.DateTime.ToString());
                                file.SetFileID(" ");
                                file.SetExtension("GoogleDrive");
                                file.SetFileName(eventItem.Attachments[i].Title);
                                file.SetFilePath(eventItem.Attachments[i].FileUrl);
                                file.AddMeetings(eventItem.Id);
                                file.SetMissing("No");
                                fileList.AddLast(file);
                            }
                        }
                    }
                }
            }catch (Exception e)
            {
                MessageBox.Show("Network connection lost");
            }
        }