protected override async Task TestPost() { FNewlyInsertedExceptions = new List <ExceptionMark>(); int numIters = FRandom.Next(4, 10); for (int i = 0; i < numIters; ++i) { int markId = GetMarkId(); var em = new ExceptionMark { ExceptionType = AttExceptionType.CetExtendedAbsence, MarkId = markId, Comments = GetRandomString(FRandom.Next(1, 129), true), StudentExceptions = new List <StudentException>(), Modified = true }; em.StartDateTime = GetRandomStartDate(); em.EndDateTime = em.StartDateTime.AddDays(FRandom.Next(1, 60)); int numStudents = FRandom.Next(1, 6); List <int> studentsUsed = new List <int>(); for (int n = 0; n < numStudents; ++n) { int studentId = GetRandomStudentId(); if (!studentsUsed.Contains(studentId)) { em.StudentExceptions.Add(new StudentException { StudentId = studentId, Modified = true }); studentsUsed.Add(studentId); } } Uri uri = new Uri(FBaseUri, "StudentExceptions"); var response = await FClient.PostAsJsonAsync(uri.ToString(), em); await CheckStatusCodeIs(response, HttpStatusCode.Created); var se = await response.Content.ReadAsAsync <ExceptionMark>(); se.CheckSameValues(em); FNewlyInsertedExceptions.Add(se); } }
public static bool SameValue(this ExceptionMark lhs, ExceptionMark rhs) { return (lhs.ExceptionType == rhs.ExceptionType && lhs.StartDateTime == rhs.StartDateTime && lhs.EndDateTime == rhs.EndDateTime && lhs.MarkId == rhs.MarkId && lhs.MinsLate == rhs.MinsLate && lhs.Comments == rhs.Comments && lhs.OriginId == rhs.OriginId && lhs.OriginalId == rhs.OriginalId && SameStudentExceptions(lhs.StudentExceptions, rhs.StudentExceptions) && lhs.Removed == rhs.Removed); }