예제 #1
0
파일: Tests.cs 프로젝트: afpaulsen/pokemon
        public void ListAllLegendaryContainsArticuno()
        {
            List <Pokemon> AllLegendary = pokeDB.ListAllLegendary();
            Pokemon        Articuno     = pokeDB.SearchNameExplicit("Articuno");

            Assert.Contains(Articuno, AllLegendary);
        }
예제 #2
0
    /// <summary>
    /// Used to route the message to the correct method
    /// </summary>
    /// <param name="routingKey">The route</param>
    /// <param name="message">The message recieved</param>
    /// <returns></returns>
    private static Object CreateResponse(string routingKey, string message)
    {
        MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(message));
        DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(string[]));

        string[] args = ser.ReadObject(ms) as string[];
        ms.Close();

        switch (routingKey)
        {
        case "SearchType":
        {
            return(pokeDB.SearchType(args[0]));
        }

        case "ListMultType":
        {
            return(pokeDB.ListMultiType());
        }

        case "ListAllLegendary":
        {
            return(pokeDB.ListAllLegendary());
        }

        case "SearchName":
        {
            return(pokeDB.SearchName(args[0]));
        }

        case "ListHeaders":
        {
            return(pokeDB.Headers);
        }

        case "SearchHeader":
        {
            return(pokeDB.SearcHeader(args[0], Int32.Parse(args[1])));
        }

        case "Battle":
        {
            return(pokeCtrl.Battle(args[0], args[1], pokeDB));
        }

        default:
        {
            throw new InvalidOperationException("Route not found");
        }
        }
    }