public async Task DeletedTournamentsAreRejected() { var stats = @" WC - Sunday 20.00 CE(S)T 2015-11-08 Final Results After 40/40 Hills --- Ignored ---"; var response = await Client.UploadStatsAsync(stats); await ResponseAssert.Ok(response); var tournament = await Database.Query <Tournament>().FirstAsync(); await Database.Insert(new DeletedTournament { Date = tournament.Date, TournamentTypeId = tournament.TournamentTypeId, SubType = tournament.SubType }); await Database.Delete <Tournament>(tournament.Id); response = await Client.UploadStatsAsync(stats); var error = await ResponseAssert.BadRequest(response); Assert.Equal("Rejected", error.Message); }
public async Task ValidatesContentType() { var response = await Client.UploadStatsAsync("test", fileName : "test.txt", contentType : "application/pdf"); var body = await ResponseAssert.BadRequest(response); Assert.Equal("Only content type \"text/plain\" is allowed", body.Message); }
public async Task ValidatesFileExtension() { var response = await Client.UploadStatsAsync("test", fileName : "test.exe"); var body = await ResponseAssert.BadRequest(response); Assert.Equal("Only text files (.txt) are allowed", body.Message); }
public async Task ValidatesFileSize() { var response = await Client.UploadStatsAsync(new string('a', 1000001)); var body = await ResponseAssert.BadRequest(response); Assert.Equal("File too big (max 1MB)", body.Message); }
public async Task SavesFilesThatFailToParseInSeparateFolder() { var response = await Client.UploadStatsAsync("not going to be able to parse this"); await ResponseAssert.BadRequest(response); var fileOnDisk = Path.Combine(FileArchive.BasePath, "FailedToParse", "test.txt"); Assert.Equal("not going to be able to parse this", File.ReadAllText(fileOnDisk)); }