コード例 #1
0
ファイル: Receiver.cs プロジェクト: TheLonelyDev/Planning
        // Create an employee using PlanningLibrary (layered code on google contacts)
        public void createEmployee(XmlDocument doc)
        {
            // Parsing data from XmlDocument
            XmlNodeList UUID       = doc.GetElementsByTagName("UUID");
            XmlNodeList firstname  = doc.SelectNodes("//name/firstname");
            XmlNodeList lastname   = doc.SelectNodes("//name/lastname");
            XmlNodeList email      = doc.GetElementsByTagName("email");
            XmlNodeList xmlVersion = doc.GetElementsByTagName("version");

            // Logging parsed data
            Console.WriteLine(UUID[0].InnerText);
            Console.WriteLine(firstname[0].InnerText);
            Console.WriteLine(lastname[0].InnerText);
            Console.WriteLine(email[0].InnerText);
            Console.WriteLine(xmlVersion[0].InnerText);

            // Making Person(employee) with given data - makeperson converts the given data to <attendee> format
            var employee = PlanningLibrary.Program.makePerson(firstname[0].InnerText, lastname[0].InnerText, email[0].InnerText);

            // Adding the Person(employee) to google people/contacts using method from PlanningLibrary
            // Expects an <attendee> (converted var employee), UUID, version
            Attendee.InewAttendee(employee, UUID[0].InnerText, xmlVersion[0].InnerText);

            Console.WriteLine("employee successfully created");
            ControlRoom.SendConfirmationMessage("Planning: Employee successfully created");
        }
コード例 #2
0
        public static void testEvent()
        {
            GService g = new GService();
            // these always need to be changed before testing
            string uuid         = "UUIDTESTefefERezfzesefeKE12&";
            string uuid2        = "efeefefe";
            string uuid3        = "efefefefefef";
            string calendarName = "test12345634567VIJF";
            Person testPerson   = makePerson("testName2", "TestLastName", "*****@*****.**");

            Attendee.InewAttendee(testPerson, uuid, "1");
            IList <EventAttendee> attendees = new List <EventAttendee>();
            EventAttendee         test      = new EventAttendee()
            {
                //Email = "testname2",
                DisplayName = "*****@*****.**"
            };

            IList <string> UUIDS = new List <string>();

            UUIDS.Add(testPerson.UserDefined[0].Value);

            Console.WriteLine("attendee created");
            Console.ReadKey();

            //create event
            //create calendar
            var testCalendar = Calendarss.InewCalendar(makeCalendar(calendarName), uuid3, "1");

            DateTime start = new DateTime(2019, 5, 7, 14, 30, 0);
            DateTime end   = new DateTime(2019, 5, 7, 15, 30, 0);

            Google.Apis.Calendar.v3.Data.Event ev = makeEvent("1223432123HG23F2V32H2", "tesstlocation", "testDisc", start, end, convertPersonToAttendee(UUIDS));
            Eventss.InewEvent(ev, uuid3, uuid2, "1");
            Console.WriteLine("event created");
            Console.ReadKey();

            //update event
            ev.Summary = "newTestsSummery";

            Eventss.IupdateEventById(ev, uuid3, uuid2, "2");
            Console.WriteLine("event updated");
            Console.ReadKey();

            //delete event
            Eventss.IDeleteEventById(uuid2, uuid3);
            Calendarss.IdeleteCalendarById(uuid3);
            Console.WriteLine("event deleted");
            Console.ReadKey();
        }
コード例 #3
0
        //attendee tests:
        // - notExcisting calendar (create, update, delete)
        // - wrong version (update)
        // - duplication uuid/person (create)
        public static void testAttendee()
        {
            GService g          = new GService();
            string   uuid       = "UUIDTEST5234";
            Person   testPerson = makePerson("testName2", "TestLastName", "*****@*****.**");

            Attendee.InewAttendee(testPerson, uuid, "1");
            Console.WriteLine("person created");
            Console.ReadKey();

            // when we update we recieve a full body of a person + UUID
            Person updatePerson = makePerson("newTestName", "TestLastName", "*****@*****.**");

            Attendee.IupdateAttendee(updatePerson, uuid, "2");
            Console.WriteLine("updated person");
            Console.ReadKey();

            Attendee.IdeleteAttendee(uuid);
            Console.WriteLine("deleted person");
            Console.Read();
        }
コード例 #4
0
        public static void testAttendeeWrongVersion()
        {
            GService g          = new GService();
            Person   testPerson = makePerson("testName2", "TestLastName", "*****@*****.**");

            Attendee.InewAttendee(testPerson, "UUIDTEST", "1");
            Console.WriteLine("person created");
            Console.ReadKey();

            try
            {
                // update person with same version = WrongVersionException
                Person updatePerson = makePerson("newTestName", "TestLastName", "*****@*****.**");
                Attendee.IupdateAttendee(updatePerson, "UUIDTEST", "1");
                Console.WriteLine("failed, person updated");
                Console.ReadKey();
            }
            catch (WrongVersionException)
            {
                Attendee.IdeleteAttendee("UUIDTEST");
                Console.WriteLine(" worked! + deleted person");
                Console.Read();
            }
        }
コード例 #5
0
        public static void testAttendeeDuplication()
        {
            GService g          = new GService();
            Person   testPerson = makePerson("testName2", "TestLastName", "*****@*****.**");

            Attendee.InewAttendee(testPerson, "UUIDTEST", "1");
            Console.WriteLine("person created");
            Console.ReadKey();

            try
            {
                // create new person with same UUID = notFoundException
                Person updatePerson = makePerson("newTestName", "TestLastName", "*****@*****.**");
                Attendee.InewAttendee(updatePerson, "UUIDTEST", "1");
                Console.WriteLine("failed: no exception");
                Console.ReadKey();
            }
            catch (NotFoundException)
            {
                Attendee.IdeleteAttendee("UUIDTEST");
                Console.WriteLine(" worked! + deleted person");
                Console.Read();
            }
        }