public void ShouldRefreshCommandRefreshMainBrandListFirstTest() { //arrange viewModel = new CollectionViewSampleViewModel(DataManager); int originalCollectionCount = 0; //act Task.Run(async() => { await viewModel.LoadData(); }).GetAwaiter().GetResult(); viewModel.PopularBrands.Remove(viewModel.PopularBrands.FirstOrDefault()); viewModel.PopularBrands.Remove(viewModel.PopularBrands.FirstOrDefault()); originalCollectionCount = viewModel.PopularBrands.Count(); Task.Run(async() => { await viewModel.ExecuteOnRefreshCommandAsync(); }).GetAwaiter().GetResult(); //assert viewModel.PopularBrands.Count.ShouldBeGreaterThan(originalCollectionCount); viewModel.PopularBrandsFromServer.Count.ShouldBeGreaterThan(originalCollectionCount); }
public void ShouldRefreshCommandRefreshMainBrandListSecondTest() { //arrange viewModel = new CollectionViewSampleViewModel(DataManager); ObservableCollection <PopularBrandsViewModel> originalData = new ObservableCollection <PopularBrandsViewModel>(); ObservableCollection <PopularBrandsViewModel> refreshedData = new ObservableCollection <PopularBrandsViewModel>(); IEnumerable <PopularBrandsViewModel> differences; //act Task.Run(async() => { await viewModel.LoadData(); }).GetAwaiter().GetResult(); if (viewModel.PopularBrands.Count > 1000) { originalData = new ObservableCollection <PopularBrandsViewModel>(viewModel.PopularBrands); Task.Run(async() => { await viewModel.ExecuteOnRefreshCommandAsync(); }).GetAwaiter().GetResult(); refreshedData = new ObservableCollection <PopularBrandsViewModel>(viewModel.PopularBrands); differences = originalData.Except(refreshedData); } else { List <PopularBrandsViewModel> list = new List <PopularBrandsViewModel>(); list.Add(new PopularBrandsViewModel()); IEnumerable <PopularBrandsViewModel> en = list; differences = en; } //assert Assert.AreEqual(originalData.Count, refreshedData.Count); differences.Count().ShouldBeGreaterThan(0); }