Beispiel #1
0
        public void TestGettingEvents()
        {
            int          firstResult        = -1;
            int          secondResult       = -1;
            List <Event> thirdSearch        = null;
            string       name1              = "";
            string       name2              = "";
            bool         TestThrewException = false;

            try
            {
                ep.InsertEvent(testEvent.Name, testEvent.EventType, testEvent.Location,
                               testEvent.Date, testEvent.Description, testEvent.MaxNumberOfCharacters, testEvent.GuildID);

                List <Event> firstSearch  = (List <Event>)ep.GetAllGuildEvents(testEvent.GuildID);
                List <Event> secondSearch = (List <Event>)ep.GetAllGuildEventsByEventType(testEvent.GuildID, testEvent.EventType);
                thirdSearch = (List <Event>)ep.GetAllGuildEventsByEventType(testEvent.GuildID, "Super Raid");

                firstResult  = firstSearch.Count();
                secondResult = secondSearch.Count();
                name1        = firstSearch[0].Name;
                name2        = secondSearch[0].Name;
            }catch (Exception)
            {
                TestThrewException = true;
            }finally
            {
                //Cleanup
                int id = ea.GetIdOfEvent(testEvent.Name);
                ea.DeleteEventByID(id);
            }

            Assert.AreEqual(1, firstResult);
            Assert.AreEqual(1, secondResult);
            Assert.IsNull(thirdSearch);
            Assert.AreEqual(testEvent.Name, name1);
            Assert.AreEqual(testEvent.Name, name2);
            Assert.IsFalse(TestThrewException);
        }
Beispiel #2
0
        public ActionResult <List <Event> > GetByType(string guildId, string type)
        {
            IAuthService authService = new JWTService(clientSettings.Value.SecretKey);
            string       token       = HttpContext.Request.Headers["Authorization"];

            try
            {
                if (!authService.IsTokenValid(token))
                {
                    return(BadRequest("Unauthorized Access"));
                }
                else
                {
                    return(eventProcessor.GetAllGuildEventsByEventType(guildId, type).ToList());
                }
            } catch
            {
                return(BadRequest("Unauthorized Access"));
            }
        }