Exemplo n.º 1
0
        public string listofbeers([FromBody] JObject BeerNa)
        {
            string OutPutVVar = string.Empty;

            string BeerName = BeerNa["BeerName"].ToString();

            BeerName = BeerName.ToLower().Trim();
            if (BeerName == "")
            {
                return("Invalid Beer name");
            }
            DataManupulation dfdsfsd  = new DataManupulation();
            IList <BeerInfo> sdsadasd = dfdsfsd.GetAllLList("https://api.punkapi.com/v2/beers", BeerName);

            if (sdsadasd != null && sdsadasd.Count > 0)
            {
                int idBeer    = sdsadasd[0].id;
                var beerddata = dfdsfsd.GetUserDetails(idBeer);

                BeerInfo sadasd = new BeerInfo();
                sadasd.id = idBeer;

                sadasd.name        = sdsadasd[0].name;
                sadasd.description = sdsadasd[0].description;
                sadasd.userRatings = beerddata;
                var dssd = new JavaScriptSerializer().Serialize(sadasd);

                return(dssd);
            }
            else
            {
                return("Invalid Beer name");
            }
        }
Exemplo n.º 2
0
        public void TestCaseForGetAllByName()
        {
            DataManupulation dfdsfsd  = new DataManupulation();
            IList <BeerInfo> sdsadasd = dfdsfsd.GetAllLList("https://api.punkapi.com/v2/beers", "Trashy Blonde");



            Assert.AreEqual(sdsadasd.Count, 1);
            Assert.AreNotEqual(sdsadasd[0].id, 1);

            Assert.AreEqual(sdsadasd[0].name, "Trashy Blonde");

            Assert.AreNotEqual(sdsadasd[0].name, "KING fisher");
        }