public void History_Property_Return_All_HistoryItems() { //ARRANGE var historyList = new List <HistoryItem>(); historyList.Add(new HistoryItem() { Id = "1", Name = "Hogeschool Kortrijk", DateOfSearch = "1999-01-01 00:00:00", Latitude = "55.5", Longitude = "42.2" }); historyList.Add(new HistoryItem() { Id = "2", Name = "Hogeschool Gent", DateOfSearch = "2019-01-01 00:00:00", Latitude = "85.5", Longitude = "41.2" }); var mockHistoryService = new Mock <ISearchHistoryService>(); var mockNavService = new Mock <IMvxNavigationService>(); var mockMessenger = new Mock <IMvxMessenger>(); mockHistoryService.Setup(ws => ws.GetHistoryItems()).Returns(Task.FromResult(historyList)); var vm = new SearchHistoryViewModel(mockHistoryService.Object, mockNavService.Object, mockMessenger.Object); //ACT var allHistoryItems = vm.HistoryItems; //ASSERT Assert.IsNotNull(allHistoryItems); Assert.IsTrue(allHistoryItems.Count == 2); }
public Shop(int userId) { InitializeComponent(); this.userId = userId; vm = new SearchHistoryViewModel(userId); BindingContext = vm; }
public void Executing_HistoryNavCommand_Navigates_Back_To_Main_Screen() { //ARRANGE var mockNavService = new Mock <IMvxNavigationService>(); HistoryItem historyItem = new HistoryItem() { Name = "Kortrijk", DateOfSearch = DateTime.Now.ToString(), Latitude = "55.5", Longitude = "42.2" }; var vm = new SearchHistoryViewModel(null, mockNavService.Object, null); vm.HistoryNavCommand.Execute(); //ACT //ASSERT mockNavService.Verify(nav => nav.Navigate <MainViewModel>(null), Times.Once()); }
public async Task <Object> GetAllHistory(SearchHistoryViewModel model) { var data = _unitOfWork.HistoryRepository.Get(c => (model.Id == null) || c.Id.ToString().Contains(model.Id)); int totalRow = data.Count(); var dataWithPage = data.Skip((model.PageIndex - 1) * model.PageSize).Take(model.PageSize).Select(c => new HistoryViewModel() { Id = c.Id, NameOrder = c.NameOrder, CreatedDate = c.CreatedDate, TotalPrice = c.TotalPrice, IdAccount = c.IdAccount }).ToList(); var result = new PagedResult <HistoryViewModel> { TotalRecord = totalRow, Items = dataWithPage }; return(_apiResponse.Ok(result)); }
public Shop() { InitializeComponent(); vm = new SearchHistoryViewModel(); this.HistoryListView.ItemsSource = vm.histories; }
public async Task <IActionResult> GetAllHistory([FromQuery] SearchHistoryViewModel model) { var result = await _historyService.GetAllHistory(model); return(Ok(result)); }