public void TestCase() { try { var user = bll.GetUser(); if (String.IsNullOrEmpty(user.Token)) { Assert.Fail(); } else { Assert.Pass("the user is logged"); } } catch (UnauthorizedAccessException) { Assert.Pass("UnauthorizedAccessException"); } catch (System.Net.WebException) { Assert.Inconclusive("WebException"); } }
protected override void RefreshData() { LinearLayout OrderListLayout = FindViewById <LinearLayout>(Resource.Id.OrderList); OrderListLayout.RemoveAllViews(); VOUser user; foreach (var order in bll.GetSellerOrders()) { TextView tvText1 = new TextView(this) { Text = order.Id }; tvText1.SetTextSize(Android.Util.ComplexUnitType.Dip, 40f); tvText1.Click += (sender, e) => Utility.AuthenticateIfNeeded(() => { user = bll.GetUser(); if (user.Role == "Seller") { var activity2 = new Intent(this, typeof(OrderActivity)); activity2.PutExtra("OrderId", order.Id); StartActivity(activity2); } else if (user.Role == "Delivery") { var geoUri = Android.Net.Uri.Parse(String.Format("geo:0,0?q={0},{1}({2})", order.Address.Latitude, order.Address.Longitude, order.Id)); var mapIntent = new Intent(Intent.ActionView, geoUri); StartActivity(mapIntent); } else { Finish(); } }, this); OrderListLayout.AddView(tvText1); } }
/// <summary> /// Refresh the data of the main activity. /// </summary> protected override void RefreshData() { VOUser user = logicConnection.GetUser(); ToggleButton active = FindViewById <ToggleButton>(Resource.Id.toggleButton1); Button listOrders = FindViewById <Button>(Resource.Id.button1); Button newOrder = FindViewById <Button>(Resource.Id.button2); active.Checked = user.Status == statusAvailable; if (user.Role == "Delivery") { newOrder.Visibility = Android.Views.ViewStates.Invisible; } active.Click += (sender, e) => Utility.AuthenticateIfNeeded(() => { if (active.Checked) { logicConnection.ChangeStatus(statusAvailable); } else { logicConnection.ChangeStatus(statusUnavailable); } RefreshData(); }, this); listOrders.Click += delegate { Utility.AuthenticateIfNeeded(() => { StartActivity(typeof(OrderListActivity)); }, this); }; newOrder.Click += delegate { Utility.AuthenticateIfNeeded(() => { //StartActivity(typeof()); }, this); }; }