Пример #1
0
 public void WillConvertLessonStringEndSingle1()
 {
     var sut = new Data { Date = new DateTime(2015, 4, 12), Lesson = "10" };
     sut.Refresh();
     Assert.IsTrue((sut.End.Year == 2015) && (sut.End.Month == 4) && (sut.End.Day == 12) && (sut.End.Hour == 16) && (sut.End.Minute == 25));
 }
Пример #2
0
 public void MakeDateHeading()
 {
     var d = new DateTime(2017, 11, 13);
     var sut = new Data(d);
     Assert.AreEqual("Montag, 13.11", sut.Line1);
 }
Пример #3
0
 public void SecondRowGenerationCancelledLesson()
 {
     var sut = new Data { OldSubject = "PH", OutageStr = " x ", Teacher = "BL" };
     sut.Refresh();
     Assert.AreEqual("Physik bei BL entfällt.", sut.Line2);
 }
Пример #4
0
            private static Data ProceedScheduleItem(string thingy, Data individualEntry, int webColumn, int iteration, bool silent, ICollection<Data> rowsData)
            {
                switch (webColumn)
                {
                    #if LEHRER
                    case 0:
                        if (thingy == VConfig.SpecialEvtAb)
                        { individualEntry.Event = true; }
                        break;
                    case 1:
                        int day = Convert.ToInt16(thingy.Substring(0, thingy.IndexOf(".", StringComparison.Ordinal)));
                        string dayStr = thingy.Substring(thingy.IndexOf(".", StringComparison.Ordinal) + 1);
                        dayStr = dayStr.Replace(".", string.Empty);
                        int month = Convert.ToInt16(dayStr);
                        int year = DateTime.Now.Year;
                        DateTime dt = new DateTime(year, month, day);
                        individualEntry.Date = dt;
                        if (iteration == 0 && !silent)
                        {
                            rowsData.Add(new Data(dt));
                        }
                        break;
                    case 2:
                        break;
                    case 3:
                        individualEntry.Lesson = thingy;
                        break;
                    case 4:
                        individualEntry.OldSubject = thingy;
                        break;
                    case 5:
                        //time
                        break;
                    case 6:
                        individualEntry.Subject = thingy;
                        break;
                    case 7:
                        individualEntry.Teacher = thingy;
                        break;
                    case 8:
                        individualEntry.Cover = thingy;
                        break;
                    case 9:
                        individualEntry.OldGroup = thingy;
                        break;
                     case 10:
                        individualEntry.Group = thingy;
                        break;
                    case 11:
                        individualEntry.OldRoom = thingy;
                        break;
                    case 12:
                        individualEntry.Room = thingy;
                        break;
                    case 13:
                        //old lesson
                        break;
                    case 14:
                        //teacher to
                        break;
                    case 15:
                        individualEntry.OutageStr = thingy;
                        break;
                    case 16:
                        individualEntry.CareStr = thingy;
                        break;

                    #else
                    case 0:
                        if (thingy == VConfig.SpecialEvtAb)
                        { individualEntry.Event = true; }
                        break;
                    case 1:
                        int day = Convert.ToInt16(thingy.Substring(0, thingy.IndexOf(".", StringComparison.Ordinal)));
                        string dayStr = thingy.Substring(thingy.IndexOf(".", StringComparison.Ordinal) + 1);
                        dayStr = dayStr.Replace(".", string.Empty);
                        int month = Convert.ToInt16(dayStr);
                        int year = DateTime.Now.Year;
                        DateTime dt = new DateTime(year, month, day);
                        individualEntry.Date = dt;
                        if (iteration == 0 && !silent)
                        {
                            rowsData.Add(new Data(dt));
                        }
                        break;
                    case 2:
                        individualEntry.Lesson = thingy;
                        break;
                    case 3:
                        individualEntry.Cover = thingy;
                        break;
                    case 4:
                        individualEntry.Subject = thingy;
                        break;
                    case 5:
                        individualEntry.OldSubject = thingy;
                        break;
                    case 6:
                        individualEntry.Room = thingy;
                        break;
                    case 7:
                        individualEntry.Group = thingy;
                        break;
                    case 8:
                        individualEntry.Teacher = thingy;
                        break;
                    case 13:
                        individualEntry.Notice = thingy;
                        break;
                    case 14:
                        individualEntry.OutageStr = thingy;
                        break;
                    case 15:
                        individualEntry.CareStr = thingy;
                        break;
                    #endif
                }
                return individualEntry;
            }
Пример #5
0
 public void MakeHeadingEmptySecond()
 {
     const string s = "Jolla";
     var sut = new Data(s);
     Assert.IsTrue(string.IsNullOrEmpty(sut.Line2));
 }
Пример #6
0
 public void QuickInstanceInitializerWillNotBeADate()
 {
     var sut = new Data("3-4", "DE", "CHR", "MD", "E21", "");
     Assert.IsFalse(sut.DateHeader);
 }
Пример #7
0
 public void SecondRowGenerationOtherRoom()
 {
     var sut = new Data { OldSubject = "CH", Subject = "CH", Cover = "KS", Teacher = "KS", Room = "D35" };
     sut.Refresh();
     Assert.AreEqual("KS | D35", sut.Line2);
 }
Пример #8
0
 public void MakeDateHeadingEmptySecond()
 {
     var d = new DateTime(2017, 11, 13);
     var sut = new Data(d);
     Assert.IsTrue(string.IsNullOrEmpty(sut.Line2));
 }
Пример #9
0
 public void FirstRowGenerationFromMinimalData()
 {
     var sut = new Data {OldSubject = "DE", Lesson = "3"};
     sut.Refresh();
     Assert.AreEqual("3. Std: Deutsch", sut.Line1);
 }
Пример #10
0
 public void SecondRowGenerationOtherLessonWithRoom()
 {
     var sut = new Data { OldSubject = "MA", Subject = "EN", Teacher = "HC", Cover = "MUE", Room = "C17"};
     sut.Refresh();
     Assert.AreEqual("Englisch bei MUE statt Mathe | C17", sut.Line2);
 }
Пример #11
0
 public void SecondRowGenerationOnlyNewTeacherWithRoom()
 {
     var sut = new Data { Subject = "KU", Cover = "WH", Room = "112" };
     sut.Refresh();
     Assert.AreEqual("Bei WH in 112", sut.Line2);
 }
Пример #12
0
 public void SecondRowGenerationMinData()
 {
     var sut = new Data { OldSubject = "CH", Subject = "CH", Cover = "KS", Teacher = "KS"};
     sut.Refresh();
     Assert.AreEqual("KS", sut.Line2);
 }
Пример #13
0
 public void SecondRowGenerationEventWithGroup()
 {
     var sut = new Data { Subject = "DS", Event = true, Teacher = "ME", Room = "BUE", Notice = "PeoplesTheater", Group = "7A1, 7A2, 7N1"};
     sut.Refresh();
     Assert.AreEqual("Peoples Theater; Raum: BUE | Mit ME und 7A1, 7A2, 7N1", sut.Line2);
 }
Пример #14
0
 public void WillConvertLessonStringStartMultiple1()
 {
     var sut = new Data { Date = new DateTime(2015, 4, 12), Lesson = "10-11" };
     sut.Refresh();
     Assert.IsTrue((sut.Date.Year == 2015) && (sut.Date.Month == 4) && (sut.Date.Day == 12) && (sut.Date.Hour == 15) && (sut.Date.Minute == 40));
 }
Пример #15
0
 public void SecondRowGenerationOtherTeacherWithRoom()
 {
     var sut = new Data { OldSubject = "IN", Subject = "IN", Cover = "BLAU", Teacher = "ZR", Room = "D33" };
     sut.Refresh();
     Assert.AreEqual("BLAU vertritt ZR | D33", sut.Line2);
 }
Пример #16
0
 public void WillConvertLessonStringStartSingle2()
 {
     var sut = new Data { Date = new DateTime(2015, 4, 12), Lesson = "4" };
     sut.Refresh();
     Assert.IsTrue((sut.Date.Year == 2015) && (sut.Date.Month == 4) && (sut.Date.Day == 12) && (sut.Date.Hour == 10) && (sut.Date.Minute == 35));
 }
Пример #17
0
 public void SortsCorrectly()
 {
     var a = new Data(DateTime.Now);
     var b = new Data(DateTime.Now.AddDays(2));
     var c = new Data("1", "DE", "ZE", "MD", "E21", "");
     var d = new Data("1-2", "MA", "ZR", "ZS", "C14", "");
     var e = new Data("1-4", "DS", "ME", "ME", "AULA", "Sonderprobe");
     var f = new Data("4", "MU", "LK", "HAI", "317", "");
     var g = new Data("5-6", "POWI", "CHR", "CHR", "BUE", "Vortrag");
     var res = new List<Data> { e, b, d, g, f, a, c };
     res.Sort();
     var exp = new List<Data> { a, b, c, d, e, f, g };
     Assert.AreEqual(exp, res);
 }
Пример #18
0
 public void MakeHeading()
 {
     const string s = "Jolla";
     var sut = new Data(s);
     Assert.AreEqual(s, sut.Line1);
 }
Пример #19
0
 public void WillConvertCancelledStringToState()
 {
     var sut = new Data { OutageStr = " x " };
     sut.Refresh();
     Assert.IsTrue(sut.Outage);
 }
Пример #20
0
 public void QuickInstanceInitializerWillFillLine1()
 {
     var sut = new Data("3-4", "DE", "CHR", "MD", "E21", "");
     Assert.IsFalse(string.IsNullOrWhiteSpace(sut.Line2));
 }
Пример #21
0
 public void WillConvertCocareStringToState()
 {
     var sut = new Data { CareStr = " x " };
     sut.Refresh();
     Assert.IsTrue(sut.Cared);
 }
Пример #22
0
 public void RefreshReturnsSameObject()
 {
     var sut = new Data();
     Assert.AreEqual(sut, sut.Refresh());
 }
Пример #23
0
 public void WillConvertLessonStringEndMultiple2()
 {
     var sut = new Data { Date = new DateTime(2015, 4, 12), Lesson = "2-4" };
     sut.Refresh();
     Assert.IsTrue((sut.End.Year == 2015) && (sut.End.Month == 4) && (sut.End.Day == 12) && (sut.End.Hour == 11) && (sut.End.Minute == 20));
 }
Пример #24
0
 public void SecondRowGenerationCocareWithRoom()
 {
     var sut = new Data { Subject = "MU", CareStr = " x ", Teacher = "LK", Cover = "LOH", Room = "316"};
     sut.Refresh();
     Assert.AreEqual("Musik bei LK wird durch LOH mitbetreut. | 316", sut.Line2);
 }
Пример #25
0
 /// <summary>
 /// Given a string representing a table of a day in WebUntis' HTML, <see cref="ProcessRow"/> will return an object including the <see cref="Data"/> representations of each schedule value
 /// </summary>
 /// <returns>Object containing the current progress of parsing and the last <see cref="Data"/>-objects that were parsed</returns>
 /// <param name="item">The HTML string representing the table of a day</param>
 /// <param name="iOuter">The progress through the day tables</param>
 /// <param name="mode">The background operations mode. See also <seealso cref="UntisExp.Fetcher"/></param>
 /// <param name="silent">Whether the task will add headings</param>
 /// <param name="daysAndNewsBoxes">The number of news tables in the week</param>
 /// <param name="passDontImmediatelyRefresh">If appropriate, this value will be passed to <see cref="HasToGetSecondSchedule"/>.</param>
 /// <param name="activity">The action which should be performed.</param>
 public static InterstitialFetching ProcessRow(string item, int iOuter, int daysAndNewsBoxes, int mode, bool silent, bool passDontImmediatelyRefresh,int daysRec, Activity activity = Activity.ParseFirstSchedule,News news = null)
 {
     List<Data> v1 = new List<Data>();
     InterstitialFetching result = new InterstitialFetching { HasToGetSecondSchedule = passDontImmediatelyRefresh };
     if (item.IndexOf(VConfig.SearchNoAccess, StringComparison.Ordinal) == -1)
     {
         string it = item.Replace("&nbsp;", String.Empty);
         string searchInFront;
         if (activity == Activity.GetNews)
         {
             searchInFront = "<tr>";
             if(news==null)
             news = new News { Image = "http://centrallink.de/sr/Blackboard.png", Source = new Uri(VConfig.Url) };
         }
         else
         {
             searchInFront = "<trclass='list";
         }
         if ((item.IndexOf(VConfig.NoEventsText.Replace(" ", string.Empty), StringComparison.Ordinal) == -1) || activity == Activity.GetNews)
         {
             int iterations = 0;
             it = it.Substring(it.IndexOf("</tr>", StringComparison.Ordinal) + 5, it.Length - it.IndexOf("</tr>", StringComparison.Ordinal) - 5);
             while (it.IndexOf(searchInFront, StringComparison.Ordinal) != -1)
             {
                 if (iterations == 0)
                 {
                     // news box should not be a day so we count days here
                     daysRec++;
                 }
                 if (activity == Activity.GetNews)
                 {
                     if (news != null && news.Summary != null)
                     {
                         news.Summary += "\n\n";
                     }
                     DateTime date = GetDateFromDay(iOuter, Activity.ParseFirstSchedule);
                     string dateName = new CultureInfo("de-DE").DateTimeFormat.GetDayName(date.DayOfWeek);
                     if (news != null) news.Summary += dateName + ", " + date.Day + "." + date.Month + ":\n";
                 }
                 Data data = new Data();
                 string w = it.Substring(it.IndexOf(searchInFront, StringComparison.Ordinal));
                 w = w.Substring(0, w.IndexOf("</tr>", StringComparison.Ordinal));
                 it = it.Substring(it.IndexOf("</tr>", StringComparison.Ordinal) + 5, it.Length - it.IndexOf("</tr>", StringComparison.Ordinal) - 5);
                 var mc = VConfig.CellSearch.Matches(w);
                 int webColumn = 0;
                 foreach (var thing in mc)
                 {
                     string compute = PrepareScheduleItem(thing);
                     if (activity != Activity.GetNews)
                     {
                         data = ProceedScheduleItem(compute, data, webColumn, iterations, silent, v1);
                         webColumn++;
                     }
                     else
                     {
                         news = ProcessNewsItem(compute, news);
                     }
                 }
                 if (activity != Activity.GetNews)
                 {
                     data.Refresh();
                     if ((mode == 1 && daysRec == 2) || (mode != 1 && mode != 0) || (mode == 0 && daysRec == 1))
                         v1.Add(data);
                 }
                 iterations++;
             }
             //skips News-Boxes in iOuter-count to have the right current-day in iOuter
             if ((iterations == 0 && activity != Activity.GetNews) || (iterations > 0 && activity == Activity.GetNews))
             {
                 iOuter--;
             }
         }
         else
         {
             daysRec++;
             if (!silent)
             {
                 //Adds Date
                 v1.Add(new Data(GetDateFromDay(iOuter, activity)));
                 //Adds no events message
                 v1.Add(new Data());
             }
         }
     }
     iOuter++;
     if (iOuter == VConfig.ExpectedDayNum && (daysRec == 1) && mode != 0 && activity == Activity.ParseFirstSchedule)
     {
         result.HasToGetSecondSchedule = true;
     }
     result.OuterLoopCursor = iOuter;
     result.ParsedRows = v1;
     result.ParsedNews = news;
     result.RecordedDays = daysRec;
     return result;
 }