public void DownloadResourceActionWhenPracticeAndUserNotLoggedInShouldRegirectToLoginPage() { var contest = this.CreateAndSaveContest("testContest", this.InactiveContestOptions, this.ActiveContestWithPasswordOptions); var problem = new Problem { Name = "test problem" }; var resource = new ProblemResource { File = new byte[1], FileExtension = "test" }; problem.Resources.Add(resource); contest.Problems.Add(problem); this.EmptyOjsData.SaveChanges(); var controller = new CompeteController(this.EmptyOjsData, null); var result = controller.DownloadResource(resource.Id, this.IsPractice) as RedirectToRouteResult; Assert.AreEqual("Register", result.RouteValues["action"]); Assert.AreEqual(this.IsPractice, result.RouteValues["official"]); Assert.AreEqual(contest.Id, result.RouteValues["id"]); }
public void ValidateContestWhenContestCanBeCompetedShouldNotThrowAnException() { var contest = new Contest { IsVisible = true, StartTime = new DateTime(1990, 1, 1) }; CompeteController.ValidateContest(contest, true); }
public void ValidateContestWhenContestIsNotFoundShouldAndTryingToCompeteThrowException() { try { CompeteController.ValidateContest(null, true); Assert.Fail("Expected an exception when contest is null"); } catch (HttpException ex) { Assert.AreEqual((int)HttpStatusCode.NotFound, ex.GetHttpCode()); } }
public void ValidateSubmissionTypeWhenSubmissionTypeIsFoundShouldNotThrowException() { var contest = new Contest { SubmissionTypes = new List <SubmissionType> { new SubmissionType { Id = 1 }, } }; CompeteController.ValidateSubmissionType(1, contest); }
public void ValidateContestWhenContestIsDeletedAndTryingToPracticeShouldThrowException() { var contest = new Contest { IsDeleted = true }; try { CompeteController.ValidateContest(contest, false); Assert.Fail("Expected an exception when contest is null"); } catch (HttpException ex) { Assert.AreEqual((int)HttpStatusCode.NotFound, ex.GetHttpCode()); } }
public void ValidateContestWhenContestIsInvisibleAndTryingToCompeteShouldThrowException() { var contest = new Contest { IsVisible = false }; try { CompeteController.ValidateContest(contest, true); Assert.Fail("Expected an exception when trying to access a contest that is not visible"); } catch (HttpException ex) { Assert.AreEqual((int)HttpStatusCode.NotFound, ex.GetHttpCode()); } }
public void ValidateContestWhenContestCannotBePracticedShouldThrowException() { var contest = new Contest { IsVisible = true }; try { CompeteController.ValidateContest(contest, false); Assert.Fail("Expected an exception when contest is null"); } catch (HttpException ex) { Assert.AreEqual((int)HttpStatusCode.Forbidden, ex.GetHttpCode()); } }
public void ValidateContestWhenContestCanBeCompetedButTryingToPracticeItShouldThrowAnException() { var contest = new Contest { IsVisible = true, StartTime = new DateTime(1990, 1, 1) }; try { CompeteController.ValidateContest(contest, false); Assert.Fail("Expected an exception when contest is null"); } catch (HttpException ex) { Assert.AreEqual((int)HttpStatusCode.Forbidden, ex.GetHttpCode()); } }
public void ValidateSubmissionTypeWhenSubmissionTypeIsNotFoundThrowException() { var contest = new Contest { SubmissionTypes = new List <SubmissionType> { new SubmissionType { Id = 1 }, } }; try { CompeteController.ValidateSubmissionType(0, contest); Assert.Fail("Expected an exception when submission type is null"); } catch (HttpException ex) { Assert.AreEqual((int)HttpStatusCode.BadRequest, ex.GetHttpCode()); } }