public void Initialize(ProductListingViewModel viewModel)
 {
     ViewModel = (TelerikProductListingViewModel)viewModel;
     DataContext = ViewModel;
     ViewModel.GroupDescriptors = List.GroupDescriptors;
     ViewModel.SortDescriptors = List.SortDescriptors;
     ViewModel.FilterDescriptors = List.FilterDescriptors;
     ViewModel.UpdateGroupDescriptors();
     ViewModel.UpdateSortDescriptors();
     ViewModel.DescriptorsUpdating += delegate { List.BeginDataUpdate(); };
     ViewModel.DescriptorsUpdated += delegate { List.EndDataUpdate(); };
     ViewModel.Refreshed += delegate { RestoreTopItem(); };
     ViewModel.Loaded += ViewModel_Loaded;
 }
 public void HasMru(bool mruProductsPresent, bool addMru)
 {
     var factories = Substitute.For<Factories>();
     factories.Products.Returns(new List<Product>());
     factories.Categories.Returns(new List<Category>());
     factories.MruProducts.Products.Returns(new List<Product>());
     factories.Settings.Returns(new Settings());
     factories.CreateCategory().Returns(new Category());
     if (mruProductsPresent)
         factories.MruProducts.Products.Add(new Product());
     var sut = new ProductListingViewModel(factories, new BackgroundWorkerSyncFactory());
     sut.AddMru = addMru;
     sut.Load();
     Assert.AreEqual(mruProductsPresent && addMru, sut.HasMru);
 }
 public void TestInitialize()
 {
     factories = Substitute.For<Factories>();
     fixture = new Fixture();
     factories.Finder.Returns(new FinderImpl(factories));
     factories.CreateCategory().Returns(new Category());
     factories.Categories.Returns(fixture.CreateMany<Category>().ToList());
     factories.Products.Returns(fixture.CreateMany<Product>(5).ToList());
     foreach (var product in factories.Products)
     {
         product.CategoryId = factories.Categories[1].Id;
         product.SetOwner(factories);
     }
     factories.MruProducts.Returns(new MruProductsImpl(new List<Guid>(), factories));
     factories.Settings.Returns(new Settings());
     viewModel = new ProductListingViewModel(factories, new BackgroundWorkerSyncFactory());
 }
Esempio n. 4
0
 public MainViewModel(Factories factories, Cloud cloud, TimerFactory timerFactory,
     BackgroundWorkerFactory workerFactory, MealEditingViewModel.BackNavigation mealEditingBackNavigation,
     JournalViewModel journal, ProductListingViewModel productListing, MealItemEditingViewModel mealItemEditing,
     MessageDialog messageDialog, WelcomeScreen welcomeScreen, CloudMessages cloudMessages)
 {
     this.factories = factories;
     this.cloud = cloud;
     this.timerFactory = timerFactory;
     this.workerFactory = workerFactory;
     this.mealEditingBackNavigation = mealEditingBackNavigation;
     this.journal = journal;
     this.productListing = productListing;
     this.mealItemEditing = mealItemEditing;
     this.messageDialog = messageDialog;
     this.cloudMessages = cloudMessages;
     WelcomeScreen = welcomeScreen;
     ShareStateProvider();
 }
 public void TestInitialize()
 {
     factories = new FactoriesImpl();
     factories.StorageCreator = new StorageCreatorStub();
     productListing = new ProductListingViewModel(factories,
         new BackgroundWorkerSyncFactory());
     mealItemEditing = new MealItemEditingViewModel();
     sut = CreateSut(factories, productListing: productListing, mealItemEditing: mealItemEditing);
     navigation = new MainViewModel.Navigation();
     sut.Init(navigation);
     var stateProvider = Substitute.For<StateProvider>();
     stateProvider.State.Returns(new Dictionary<string, object>());
     sut.StateProvider = stateProvider;
     navigator = Substitute.For<Navigator>();
 }
 private MainViewModel CreateSut(Factories factories = null, Cloud cloud = null,
     TimerFactory timerFactory = null, ProductListingViewModel productListing = null,
     MealItemEditingViewModel mealItemEditing = null, MessageDialog messageDialog = null,
     WelcomeScreen welcomeScreen = null, CloudMessages cloudMessages = null)
 {
     if (factories == null)
         factories = Substitute.For<Factories>();
     if (cloud == null)
         cloud = Substitute.For<Cloud>();
     if (timerFactory == null)
         timerFactory = Substitute.For<TimerFactory>();
     if (productListing == null)
         productListing = new ProductListingViewModel(factories, new BackgroundWorkerSyncFactory());
     if (mealItemEditing == null)
         mealItemEditing = new MealItemEditingViewModel();
     if (messageDialog == null)
         messageDialog = Substitute.For<MessageDialog>();
     if (welcomeScreen == null)
         welcomeScreen = new WelcomeScreenImpl(messageDialog);
     if (cloudMessages == null)
         cloudMessages = new CloudMessages();
     var journal = new JournalViewModel(factories, new BackgroundWorkerSyncFactory(),
         new SugarEditingViewModel());
     return new MainViewModel(factories, cloud, timerFactory, new BackgroundWorkerSyncFactory(),
         new MealEditingViewModel.BackNavigation(), journal, productListing, mealItemEditing, messageDialog,
         welcomeScreen, cloudMessages);
 }
 public CategoriesAndProductsLoader(ProductListingViewModel viewModel, bool addMru)
     : base(viewModel.workerFactory)
 {
     this.viewModel = viewModel;
     factories = viewModel.factories;
     maxCuAndFpu = viewModel.maxCuAndFpu;
     this.addMru = addMru;
 }