Example #1
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());
             */
        }
        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");
        }
        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");
                }
            }
        }