Beispiel #1
0
        public async Task ModifyAsync()
        {
            var adminId = (await UserUtils.GetAdmin()).Id;
            var stuId   = (await UserUtils.GetStudent()).Id;

            var problem = new Data.Problem
            {
                Name   = Guid.NewGuid().ToString(),
                UserId = adminId
            };
            var id = await service.CreateProblemAsync(problem);

            Assert.AreNotEqual(0, id);

            var studentResult = await service.QueryProblemAsync(stuId);

            Assert.IsTrue(studentResult /*.Cacheable()*/.Any(i => i.Id == id && i.Name == problem.Name));

            var newName = Guid.NewGuid().ToString();

            problem.Name = newName;
            await service.UpdateProblemAsync(problem);

            studentResult = await service.QueryProblemAsync(stuId);

            Assert.IsTrue(studentResult /*.Cacheable()*/.Any(i => i.Id == id && i.Name == problem.Name));

            await service.RemoveProblemAsync(id);

            studentResult = await service.QueryProblemAsync(stuId);

            Assert.IsFalse(studentResult /*.Cacheable()*/.Any(i => i.Id == id));
        }
Beispiel #2
0
        public async Task ConfigAsync()
        {
            var adminId = (await UserUtils.GetAdmin()).Id;
            var stuId   = (await UserUtils.GetStudent()).Id;

            var contest = new Data.Contest
            {
                Name   = Guid.NewGuid().ToString(),
                UserId = adminId
            };

            var cid = await contestService.CreateContestAsync(contest);

            Assert.AreNotEqual(0, cid);

            var problem = new Data.Problem
            {
                Name   = Guid.NewGuid().ToString(),
                UserId = adminId
            };

            var pid = await problemService.CreateProblemAsync(problem);

            Assert.AreNotEqual(0, pid);

            await contestService.UpdateContestProblemAsync(cid, new[] { pid, pid });

            var result = await problemService.QueryProblemAsync(stuId, cid);

            Assert.IsTrue(result /*.Cacheable()*/.Count(i => i.Id == pid) == 1);

            await contestService.UpdateContestProblemAsync(cid, new int[0]);

            result = await problemService.QueryProblemAsync(stuId, cid);

            Assert.IsFalse(result /*.Cacheable()*/.Any());
        }