public async Task Test_GetProduct() { ProductEntity product = new ProductEntity(); product.ID = 1; product.Name = "Bananas"; product.Kind = "Vaisius"; ProductEntity product2 = new ProductEntity(); product2 = await prServices.GetProductAsync("api/product/get?productID=1"); Assert.AreEqual(product.ID, product2.ID); Assert.AreEqual(product.Name, product2.Name); Assert.AreEqual(product.Kind, product2.Kind); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); /* * // Set our view from the "main" layout resource * SetContentView(Resource.Layout.Main); * // http://217.117.27.42:8090/internal/api/product/1 * this.client.BaseAddress = new Uri("http://217.117.27.42:8090/internal/"); * this.client.MaxResponseContentBufferSize = 250000; * this.client.DefaultRequestHeaders.Accept.Clear(); * this.client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); */ // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.MyButton); // button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); }; AsyncProductServices prservices = new AsyncProductServices(); button.Click += async(sender, args) => { // EditText editID = FindViewById<EditText>(Resource.Id.editTextID); // int product_id = Int32.Parse("1"); var prod = await prservices.GetProductAsync(); // EditText editName = FindViewById<EditText>(Resource.Id.editTextName); if (prod != null) { button.Text = prod.Name; } else { button.Text = "try again..."; } }; }