public HomeBaseViewModel() { if (_catalogService == null) { _catalogService = LocatorViewModel.Resolve <ICatalogService>(); } }
public App() { InitializeComponent(); //check if device is connected to internet //https://docs.microsoft.com/en-us/xamarin/essentials/connectivity?context=xamarin%2Fxamarin-forms&tabs=ios var current = Connectivity.NetworkAccess; if (current != NetworkAccess.Internet) { MainPage = new NoInternetPage(); return; } if (_localizationService == null) { _localizationService = LocatorViewModel.Resolve <ILocalizationService>(); } if (_customerService == null) { _customerService = LocatorViewModel.Resolve <ICustomerService>(); } CurrentCostumerSettings = new CustomerSettingModel(); _customerService.SetCurrentCustomer(true, true); _localizationService.CreateOrUpdateLocales(); InitApp(); }
public AppNavigationBaseViewModel() { if (_customerService == null && App.CurrentCostumer == null) { _customerService = LocatorViewModel.Resolve <ICustomerService>(); } }
public void ApplyPresetLocation_NoSelectedWindows_ShouldNotCallRelocateWindow() { // Prepare var location = new Location(HorizontalLocationType.Left, VerticalLocationType.Center); var eventAggregatorMock = new Mock <IEventAggregator>(); var activeWindowsSelectionChangedEventMock = new Mock <ActiveWindowsSelectionChangedEvent>(); eventAggregatorMock.Setup(x => x.GetEvent <ActiveWindowsSelectionChangedEvent>()).Returns(activeWindowsSelectionChangedEventMock.Object); var windowServiceMock = new Mock <IWindowService>(); var displayServiceMock = new Mock <IDisplayService>(); var viewModel = new LocatorViewModel(eventAggregatorMock.Object, windowServiceMock.Object, displayServiceMock.Object) { SelectedDisplay = new Display { WorkArea = new Rect { Left = 0, Top = 0, Right = 500, Bottom = 500 } } }; // Act viewModel.ApplyPresetLocation(location); // Assert windowServiceMock.Verify(x => x.RelocateWindow(It.IsAny <Domain.Windows.Window>(), It.IsAny <Rect>()), Times.Never()); }
public CategoryNavigationViewModel() { if (_catalogService == null) { _catalogService = LocatorViewModel.Resolve <ICatalogService>(); } }
public void ApplyCustomLocation_ShouldCreateRect(int?horizontalLocation, int?verticalLocation) { // Prepare Rect?createdRect = default; var eventAggregatorMock = new Mock <IEventAggregator>(); var activeWindowsSelectionChangedEventMock = new Mock <ActiveWindowsSelectionChangedEvent>(); eventAggregatorMock.Setup(x => x.GetEvent <ActiveWindowsSelectionChangedEvent>()).Returns(activeWindowsSelectionChangedEventMock.Object); var windowServiceMock = new Mock <IWindowService>(); windowServiceMock.Setup(x => x.RelocateWindow(It.IsAny <Domain.Windows.Window>(), It.IsAny <Rect>())) .Callback <Domain.Windows.Window, Rect>((window, rect) => createdRect = rect); var displayServiceMock = new Mock <IDisplayService>(); var viewModel = new LocatorViewModel(eventAggregatorMock.Object, windowServiceMock.Object, displayServiceMock.Object) { NewHorizontalLocation = horizontalLocation.ToString() ?? string.Empty, NewVerticalLocation = verticalLocation.ToString() ?? string.Empty }; viewModel.SelectedWindows.Add(new Domain.Windows.Window()); // Act viewModel.ApplyCustomLocation(); // Assert windowServiceMock.Verify(x => x.RelocateWindow(It.IsAny <Domain.Windows.Window>(), It.IsAny <Rect>()), Times.AtLeastOnce()); Assert.Equal(horizontalLocation ?? 0, createdRect?.Left); Assert.Equal(verticalLocation ?? 0, createdRect?.Top); }
// First action called when application runs public ActionResult Index() { // create variable to keep track of the user ID int userId; // check to see if the user id is stored in session if (Session["UserId"] != null) { // assign logged in users id to variable userId = Convert.ToInt32(Session["UserId"]); } // check to see if the users cityId is stored as a cookie if (Request.Cookies["cityId"] != null) { // if so get the cookie and send the user to homescreen for that city int cityId = Convert.ToInt32(Request.Cookies["cityId"].Value); HomeIndexViewModel model = new HomeIndexViewModel(cityId); return(View("Index", model)); } else { // send the user to locator page to select their current city LocatorViewModel model = new LocatorViewModel(); return(View("Locator", model)); } }
public RegisterViewModel() { if (_customerService == null) { _customerService = LocatorViewModel.Resolve <ICustomerService>(); } }
private void App_Startup(object sender, StartupEventArgs e) { _model = new LocatorModel(); _viewModel = new LocatorViewModel(_model); _viewModel.ExitGame += new EventHandler(ViewModel_ExitGame); _view = new MainWindow(); _view.DataContext = _viewModel; _view.Show(); }
public CustomerViewModel() { if (_customerService == null) { _customerService = LocatorViewModel.Resolve <ICustomerService>(); } if (_catalogService == null) { _catalogService = LocatorViewModel.Resolve <ICatalogService>(); } }
public LoginViewModel() { if (_customerService == null) { _customerService = LocatorViewModel.Resolve <ICustomerService>(); } if (_topicService == null) { _topicService = LocatorViewModel.Resolve <ITopicService>(); } }
public ItemViewTemplate() { InitializeComponent(); if (_shoppingCartService == null) { _shoppingCartService = LocatorViewModel.Resolve <IShoppingCartService>(); } if (_navigationService == null) { _navigationService = LocatorViewModel.Resolve <INavigationService>(); } }
public SelectListPage() { InitializeComponent(); if (_customerService == null) { _customerService = LocatorViewModel.Resolve <ICustomerService>(); } if (_localizationService == null) { _localizationService = LocatorViewModel.Resolve <ILocalizationService>(); } }
public CustomerView() { InitializeComponent(); View = this; if (BindingContext == null) { BindingContext = new CustomerViewModel(); } if (_customerService == null) { _customerService = LocatorViewModel.Resolve <ICustomerService>(); } }
public void Construct_ValidConstruction_ShouldCreateUtilitiesViewModel() { // Prepare var eventAggregatorMock = new Mock <IEventAggregator>(); var activeWindowsSelectionChangedEventMock = new Mock <ActiveWindowsSelectionChangedEvent>(); var windowServiceMock = new Mock <IWindowService>(); var displayServiceMock = new Mock <IDisplayService>(); eventAggregatorMock.Setup(x => x.GetEvent <ActiveWindowsSelectionChangedEvent>()).Returns(activeWindowsSelectionChangedEventMock.Object); // Act var viewModel = new LocatorViewModel(eventAggregatorMock.Object, windowServiceMock.Object, displayServiceMock.Object); // Assert Assert.NotNull(viewModel); }
public ProductViewModel() { if (_productService == null) { _productService = LocatorViewModel.Resolve <IProductService>(); } if (_shoppingCartService == null) { _shoppingCartService = LocatorViewModel.Resolve <IShoppingCartService>(); } if (_customerService == null) { _customerService = LocatorViewModel.Resolve <ICustomerService>(); } }
// called when a user clicks a subcategory id to view listings public ActionResult Index(int subcategoryId) { // check to make sure city id cookie is populated if (Request.Cookies["cityId"] != null) { // return the view listings with the city and subcategory id int cityId = Convert.ToInt32(Request.Cookies["cityId"].Value); ViewListingsViewModel model = new ViewListingsViewModel(cityId, subcategoryId); return(View("ViewListings", model)); } else { // there is no selected city id so send user to locator to chose a city LocatorViewModel locatorModel = new LocatorViewModel(); Response.Redirect("/Home/Locator"); return(View()); } }
public void ApplyCustomLocation_NoSelectedWindows_ShouldNotCallResizeWindow() { // Prepare var eventAggregatorMock = new Mock <IEventAggregator>(); var activeWindowsSelectionChangedEventMock = new Mock <ActiveWindowsSelectionChangedEvent>(); eventAggregatorMock.Setup(x => x.GetEvent <ActiveWindowsSelectionChangedEvent>()).Returns(activeWindowsSelectionChangedEventMock.Object); var windowServiceMock = new Mock <IWindowService>(); var displayServiceMock = new Mock <IDisplayService>(); var viewModel = new LocatorViewModel(eventAggregatorMock.Object, windowServiceMock.Object, displayServiceMock.Object); // Act viewModel.ApplyCustomLocation(); // Assert windowServiceMock.Verify(x => x.RelocateWindow(It.IsAny <Domain.Windows.Window>(), It.IsAny <Rect>()), Times.Never()); }
public void Construct_ValidConstruction_ShouldGetAllDisplays() { // Prepare var eventAggregatorMock = new Mock <IEventAggregator>(); var activeWindowsSelectionChangedEventMock = new Mock <ActiveWindowsSelectionChangedEvent>(); var windowServiceMock = new Mock <IWindowService>(); var displayServiceMock = new Mock <IDisplayService>(); eventAggregatorMock.Setup(x => x.GetEvent <ActiveWindowsSelectionChangedEvent>()).Returns(activeWindowsSelectionChangedEventMock.Object); displayServiceMock.Setup(x => x.GetAllDisplays()).Returns(new List <Display> { new Display { Id = 1, DisplayHandle = (IntPtr)1, Primary = false, WorkArea = new Rect() } }); // Act var viewModel = new LocatorViewModel(eventAggregatorMock.Object, windowServiceMock.Object, displayServiceMock.Object); // Assert displayServiceMock.Verify(x => x.GetAllDisplays(), Times.Once); Assert.NotNull(viewModel.AvailableDisplays); Assert.True(viewModel.AvailableDisplays.Count == 1); }
public void ApplyPresetLocation_ValidLocation_ShouldCreateRect() { // Prepare var location = new Location(HorizontalLocationType.Left, VerticalLocationType.Top); Rect?sendRect = default; var eventAggregatorMock = new Mock <IEventAggregator>(); var activeWindowsSelectionChangedEventMock = new Mock <ActiveWindowsSelectionChangedEvent>(); eventAggregatorMock.Setup(x => x.GetEvent <ActiveWindowsSelectionChangedEvent>()).Returns(activeWindowsSelectionChangedEventMock.Object); var windowServiceMock = new Mock <IWindowService>(); windowServiceMock.Setup(x => x.RelocateWindow(It.IsAny <Domain.Windows.Window>(), It.IsAny <Rect>())) .Callback <Domain.Windows.Window, Rect>((window, rect) => sendRect = rect); var displayServiceMock = new Mock <IDisplayService>(); var viewModel = new LocatorViewModel(eventAggregatorMock.Object, windowServiceMock.Object, displayServiceMock.Object) { SelectedDisplay = new Display { WorkArea = new Rect { Left = 0, Top = 0, Right = 500, Bottom = 500 } } }; viewModel.SelectedWindows.Add(new Domain.Windows.Window()); // Act viewModel.ApplyPresetLocation(location); // Assert windowServiceMock.Verify(x => x.RelocateWindow(It.IsAny <Domain.Windows.Window>(), It.IsAny <Rect>()), Times.Once()); Assert.Equal(new Rect(), sendRect); }
public MovementManager(SnakeViewModel snakeVM, FoodViewModel foodVM) { Locator = new LocatorViewModel(); this.snakeVM = snakeVM; this.foodVM = foodVM; }
private static ViewModel CreateViewModel <ViewModel>() where ViewModel : BaseViewModel { return(LocatorViewModel.Resolve <ViewModel>()); }
// sends the user to the locator page to select their city public ActionResult Locator() { LocatorViewModel model = new LocatorViewModel(); return(View("Locator", model)); }