public void ListAndCount() { //create an instance of a class clsTicketCollection AllTicket = new clsTicketCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List <clsTicket> TestList = new List <clsTicket>(); //add an item to the list //create the item of test data clsTicket TestItem = new clsTicket(); //set its properties TestItem.TicketID = 1; TestItem.TicketPurchaseDate = DateTime.Now.Date; TestItem.TicketNo = "ASD456GH"; TestItem.FlightNo = 535; TestItem.SeatNo = "53B"; //add the item to the test list TestList.Add(TestItem); //assign the data to the property AllTicket.TicketList = TestList; //test to see that the two values are the same Assert.AreEqual(AllTicket.Count, TestList.Count); }
//search database for pending bus trip and sync to server public static async Task UploadPendingRecord() { try { if (NetworkCheck.IsInternet()) { if (!(String.IsNullOrEmpty(Ultis.Settings.SessionSettingKey))) { //upload bus trip record var pendingBusTrip = App.Database.GetPendingTrip(); List <clsTrip> completeTrips = new List <clsTrip>(); foreach (BusTrip busTrip in pendingBusTrip) { if (busTrip.EndTime != null && busTrip.Uploaded == false) { clsTrip trip = new clsTrip { Id = busTrip.Id, TruckId = busTrip.TruckId, DriverId = busTrip.DriverId, StartTime = busTrip.StartTime, StartOdometer = 0, StartLocationName = "", StartGeoLoc = busTrip.StartGeoLoc, EndTime = busTrip.EndTime, EndOdometer = 0, EndLocationName = "", EndGeoLoc = busTrip.EndGeoLoc, TrxStatus = 5, LinkId = "", LocationList = {}, Captions = {} }; completeTrips.Add(trip); } } if (completeTrips.Count != 0) { var content = await CommonFunction.CallWebService(1, completeTrips, Ultis.Settings.SessionBaseURI, ControllerUtil.postTrips(), null); clsResponse response = JsonConvert.DeserializeObject <clsResponse>(content); if (response.IsGood) { /*foreach (clsTrip uploadedTrip in completeTrips) * { * var completedTrip = App.Database.GetUploadedTrip(uploadedTrip.Id); * * if (completedTrip != null) * { * completedTrip.Uploaded = true; * * App.Database.SaveBusTrip(completedTrip); * } * }*/ App.Database.DeleteBusTrip(); //upload bus ticket record var pendingTicket = App.Database.GetSoldTicket(); List <clsTicket> tickets = new List <clsTicket>(); foreach (SoldTicket soldTicket in pendingTicket) { if (!(String.IsNullOrEmpty(soldTicket.TripId))) { clsTicket ticket = new clsTicket { TrxTime = soldTicket.TrxTime, TruckId = soldTicket.TruckId, DriverId = soldTicket.DriverId, TripId = soldTicket.TripId, RouteId = soldTicket.RouteId, StopId = soldTicket.StopId, TicketType = soldTicket.TicketType, PaymentType = soldTicket.PaymentType, Amount = soldTicket.Amount }; tickets.Add(ticket); } } if (tickets.Count != 0) { var ticket_content = await CommonFunction.CallWebService(1, tickets, Ultis.Settings.SessionBaseURI, ControllerUtil.postTickets(), null); clsResponse ticket_response = JsonConvert.DeserializeObject <clsResponse>(ticket_content); if (ticket_response.IsGood) { /*foreach (clsTicket ticket in tickets) * { * var completeTicket = App.Database.GetUploadedTicket(ticket.); * * if (completeTicket != null) * { * completeTicket.Uploaded = true; * * App.Database.SaveTicketTransaction(completeTicket); * } * }*/ App.Database.DeleteTicket(); var test = App.Database.gettesting(); } } } } } } } catch { } }