Exemplo n.º 1
0
        protected override async Task TestPost()
        {
            Uri uri = new Uri(FBaseUri, "StudentMarks");

            var response = await FClient.PostAsJsonAsync(uri.ToString(), FStudentMarks[0]);

            await CheckStatusCodeIs(response, HttpStatusCode.MethodNotAllowed);
        }
Exemplo n.º 2
0
        protected override async Task TestPost()
        {
            var reg      = FRegisters[0];
            Uri uri      = new Uri(FBaseUri, "Registers");
            var response = await FClient.PostAsJsonAsync(uri.ToString(), reg);

            await CheckStatusCodeIs(response, HttpStatusCode.MethodNotAllowed);
        }
Exemplo n.º 3
0
        protected override async Task TestPost()
        {
            Uri uri = new Uri(FBaseUri, "StudentTimesInOut");

            var t        = new SimpleStudentTimesPoco();
            var response = await FClient.PostAsJsonAsync(uri.ToString(), t);

            await CheckStatusCodeIs(response, HttpStatusCode.MethodNotAllowed);
        }
Exemplo n.º 4
0
        protected override async Task TestPostDuplicate()
        {
            if (FNewlyInsertedOLAMarks.Count > 0)
            {
                Uri uri = new Uri(FBaseUri, "OLAStaging");

                // try to add a defn that already exists...
                var md       = FNewlyInsertedOLAMarks[0];
                var response = await FClient.PostAsJsonAsync(uri.ToString(), md);
                await CheckStatusCodeIs(response, HttpStatusCode.InternalServerError);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        protected override async Task TestPostDuplicate()
        {
            if (FNewlyInsertedDefinitions.Count > 0)
            {
                Uri uri = new Uri(FBaseUri, "MarkDefinitions");

                // try to add a defn that already exists...
                var md       = FNewlyInsertedDefinitions[0];
                var response = await FClient.PostAsJsonAsync(uri.ToString(), md);
                await CheckStatusCodeIs(response, HttpStatusCode.InternalServerError); // we left md.Id non-zero

                int origId = md.Id;
                md.Id = 0;

                response = await FClient.PostAsJsonAsync(uri.ToString(), md);
                await CheckStatusCodeIs(response, HttpStatusCode.Conflict);

                md.Id = origId;
            }
        }
Exemplo n.º 7
0
        protected override async Task TestPost()
        {
            FNewlyInsertedDefinitions = new List <MarkDefinition>();

            Uri uri = new Uri(FBaseUri, "MarkDefinitions");

            int numIters = FRandom.Next(4, 10);

            for (int n = 0; n < numIters; ++n)
            {
                string notifyText = GetRandomStringOrEmpty(FRandom.Next(10, 255), true);

                var newDefn = new MarkDefinition
                {
                    Abbreviation = GetUniqueAbbreviation(),
                    Name         = GetUniqueName(),
                    Card         = false,
                    Colour       = GetRandomColour(),
                    Definition   = GetRandomDef(),
                    Description  = GetRandomStringOrEmpty(FRandom.Next(10, 128), true),
                    Notification = notifyText,
                    Notify       = !string.IsNullOrWhiteSpace(notifyText),
                    OriginId     = null,
                    OriginalId   = string.Empty,
                    Precedence   = false,
                    ShortcutKey  = GetUniqueShortcutKey()
                };

                var response = await FClient.PostAsJsonAsync(uri.ToString(), newDefn);
                await CheckStatusCodeIs(response, HttpStatusCode.Created);

                var md = await response.Content.ReadAsAsync <MarkDefinition>();

                md.CheckSameValues(newDefn);

                FNewlyInsertedDefinitions.Add(md);
            }
        }
Exemplo n.º 8
0
        protected override async Task TestPost()
        {
            FNewlyInsertedOLAMarks = new List <OlaMark>();

            Uri uri = new Uri(FBaseUri, "OLAStaging");

            int numIters = FRandom.Next(4, 10);

            for (int n = 0; n < numIters; ++n)
            {
                var newDefn = new OlaMark
                {
                    Session        = FRandom.Next(),
                    MarkStamp      = GetRandomDate(),
                    MarkAbbrev     = GetRandomString(1, false),
                    MarkingUserId  = FRandom.Next(),
                    MarkId         = FRandom.Next(),
                    Student        = GetRandomString(FRandom.Next(1, 129), true),
                    StudentContext = 1,
                    Room           = GetRandomString(FRandom.Next(1, 129), true),
                    RoomContext    = 1,
                    Status         = FRandom.Next(),
                    Uploaded       = DateTime.Now,
                    Processed      = FRandom.Next(0, 100)
                };

                if (FRandom.Next(0, 2) == 1)
                {
                    newDefn.StudentId = FRandom.Next();
                }

                if (FRandom.Next(0, 2) == 1)
                {
                    newDefn.RoomId = FRandom.Next();
                }

                if (FRandom.Next(0, 2) == 1)
                {
                    newDefn.EventId = FRandom.Next();
                }

                if (FRandom.Next(0, 2) == 1)
                {
                    newDefn.Week = FRandom.Next();
                }

                var response = await FClient.PostAsJsonAsync(uri.ToString(), newDefn);
                await CheckStatusCodeIs(response, HttpStatusCode.Created);

                var md = await response.Content.ReadAsAsync <OlaMark>();

                md.CheckSameValues(newDefn);

                FNewlyInsertedOLAMarks.Add(md);
            }

            // perform the GETItem check here...
            foreach (var m in FNewlyInsertedOLAMarks)
            {
                uri = new Uri(FBaseUri, string.Format("OLAStaging/{0}", m.Id));

                var response = await FClient.GetAsync(uri);
                await CheckSuccessStatusCode(response);

                var md = await response.Content.ReadAsAsync <OlaMark>();

                md.CheckSameValues(m);
            }
        }