public void TestNumberOfParticipants() { int beforeJoin = -1; int afterJoin = -1; bool TestThrewException = false; try { beforeJoin = ecp.ParticipantsInEvent(testEvent.EventID); ecp.JoinEvent(testEvent.EventID, testCharacter.Name, "AFK", new DateTime(2020, 12, 24)); afterJoin = ecp.ParticipantsInEvent(testEvent.EventID); }catch (Exception) { TestThrewException = true; }finally { //Cleanup } Assert.AreEqual(0, beforeJoin); Assert.AreEqual(1, afterJoin); Assert.IsFalse(TestThrewException); }
public ActionResult <int> GetNumberOfSignedParticipants(string eventId) { IAuthService authService = new JWTService(clientSettings.Value.SecretKey); string token = HttpContext.Request.Headers["Authorization"]; try { if (!authService.IsTokenValid(token)) { return(BadRequest("Unauthorized Access")); } else { return(eventCharacterProcessor.ParticipantsInEvent(Int32.Parse(eventId))); } } catch { return(BadRequest("Unauthorized Access")); } }