Пример #1
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));
 }
Пример #2
0
 public void RefreshReturnsSameObject()
 {
     var sut = new Data();
     Assert.AreEqual(sut, sut.Refresh());
 }
Пример #3
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));
 }
Пример #4
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));
 }
Пример #5
0
 public void WillConvertCocareStringToState()
 {
     var sut = new Data { CareStr = " x " };
     sut.Refresh();
     Assert.IsTrue(sut.Cared);
 }
Пример #6
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));
 }
Пример #7
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);
 }
Пример #8
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);
 }
Пример #9
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);
 }
Пример #10
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);
 }
Пример #11
0
 public void FirstRowGenerationFromMinimalData()
 {
     var sut = new Data {OldSubject = "DE", Lesson = "3"};
     sut.Refresh();
     Assert.AreEqual("3. Std: Deutsch", sut.Line1);
 }
Пример #12
0
 public void SecondRowGenerationOnlyNewTeacherWithRoom()
 {
     var sut = new Data { Subject = "KU", Cover = "WH", Room = "112" };
     sut.Refresh();
     Assert.AreEqual("Bei WH in 112", sut.Line2);
 }
Пример #13
0
 public void SecondRowGenerationMinData()
 {
     var sut = new Data { OldSubject = "CH", Subject = "CH", Cover = "KS", Teacher = "KS"};
     sut.Refresh();
     Assert.AreEqual("KS", sut.Line2);
 }
Пример #14
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);
 }
Пример #15
0
 public void WillConvertCancelledStringToState()
 {
     var sut = new Data { OutageStr = " x " };
     sut.Refresh();
     Assert.IsTrue(sut.Outage);
 }
Пример #16
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);
 }
Пример #17
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;
 }