private FavoritesController NewController() { List <Claim> claims = new List <Claim>() { // Passing in username as parameter new Claim(ClaimTypes.Name, "Ted"), }; ClaimsIdentity identity = new ClaimsIdentity(claims, "TestAuthType"); ClaimsPrincipal claimsPrincipal = new ClaimsPrincipal(identity); UserSqlDAO userDao = new UserSqlDAO(ConnectionString); FavoritesSqlDAO favoritesDao = new FavoritesSqlDAO(ConnectionString); FavoritesController controller = new FavoritesController(userDao, favoritesDao) { ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = claimsPrincipal } } }; return(controller); }
/* ************************ * VISUAL SWYPE (ITEM MOVE) * ************************ */ private async void ItemSwipeTriggerComplete(object sender, LLM.SwipeCompleteEventArgs args) { LLM.LLMListViewItem item = (LLM.LLMListViewItem)sender; Quote quote = (Quote)item.Content; if (args.SwipeDirection == LLM.SwipeDirection.Left) { quote.IsShared = false; Controller.share(quote); } else { // Favorite/Un-Favorite if (FavoritesController.IsFavorite(quote.Link)) { // Remove from favorites bool result = await FavoritesController.RemoveFavorite(quote); if (result) { quote.IsFavorite = false; } } else { // Add to favorites bool result = await FavoritesController.AddFavorite(quote); if (result) { quote.IsFavorite = true; } } } }
public void DeleteTest() { var controller = new FavoritesController(_context); var result = controller.Delete("Item1"); Assert.True(result != null); }
public FavoritesODataControllerTests() { var favoritesService = new Mock <IFavoritesService>(); _controller = new FavoritesController(favoritesService.Object); favoritesService.Setup(s => s.GetAsync(default))
private async void Favorite_Tapped(object sender, TappedRoutedEventArgs e) { FontIcon icon = (FontIcon)sender; Quote quote = (Quote)icon.DataContext; if (FavoritesController.IsFavorite(quote.Link)) { // Remove from favorites bool result = await FavoritesController.RemoveFavorite(quote); if (result) { quote.IsFavorite = false; } } else { // Add to favorites bool result = await FavoritesController.AddFavorite(quote); if (result) { quote.IsFavorite = true; } } }
public void GetByIdTest() { var controller = new FavoritesController(_context); var result = controller.GetById(1); Assert.True(result != null); }
/* *************** * EVENTS HANDLERS * *************** */ private async void Favorite_Tapped(object sender, TappedRoutedEventArgs e) { FontIcon icon = (FontIcon)sender; Quote quote = (Quote)icon.DataContext; bool result = await FavoritesController.RemoveFavorite(quote, FavoritesController.CollectionType.favorites); }
public LibraryTabElement(Action <string> onObjectFieldDoubleClick, CustomMenuController customMenuController, GraphTypeMetadata graphTypeMetadata) { OnObjectFieldDoubleClick = onObjectFieldDoubleClick; var uxmlAsset = Resources.Load <VisualTreeAsset>(ResourceAssetPaths.LibraryTabElement_UXML); uxmlAsset.CloneTree(this); m_currentGraphDisplay = this.Q <ObjectDisplayField>(OPENED_GRAPH_FIELD); m_createGraphInstanceButton = this.Q <Button>(CREATE_GRAPH_INSTANCE_BUTTON); m_generateGraphClassButton = this.Q <Button>(GENERATE_GRAPH_CLASS_BUTTON); m_generateNodeClassButton = this.Q <Button>(GENERATE_NODE_CLASS_BUTTON); m_generateNodeViewDrawerClassButton = this.Q <Button>(GENERATE_NODEVIEWDRAWER_CLASS_BUTTON); m_graphTypeMetadata = graphTypeMetadata; m_recentsController = new RecentsController(this); m_favoritesController = new FavoritesController(this); m_allGraphsController = new AllGraphsController(this); m_customMenuController = customMenuController; m_customMenuController.AddCustomMenu("CreateGraphInstance", new CreateGraphInstanceCustomMenu(m_graphTypeMetadata)); m_customMenuController.AddCustomMenu("GenerateGraphClass", new GenerateGraphClassCustomMenu()); m_customMenuController.AddCustomMenu("GenerateNodeClass", new GenerateNodeClassCustomMenu(m_graphTypeMetadata)); m_customMenuController.AddCustomMenu("GenerateNodeViewDrawerClass", new GenerateNodeViewDrawerClassCustomMenu(m_graphTypeMetadata)); m_createGraphInstanceButton.clicked += () => { m_customMenuController.ShowCustomMenu("CreateGraphInstance"); }; m_generateGraphClassButton.clicked += () => { m_customMenuController.ShowCustomMenu("GenerateGraphClass"); }; m_generateNodeClassButton.clicked += () => { m_customMenuController.ShowCustomMenu("GenerateNodeClass"); }; m_generateNodeViewDrawerClassButton.clicked += () => { m_customMenuController.ShowCustomMenu("GenerateNodeViewDrawerClass"); }; }
public void CreateTest() { var controller = new FavoritesController(_context); News newsItem = new News { NewsTitle = "Title", NewsDescription = "Desc" }; var result = controller.Create(newsItem); Assert.True(result != null); }
public FavoritesControllerShould() { _favoritesQueryMock = new Mock <IFavoritesQuery>(); _vendorsQueryMock = new Mock <IVendorsQuery>(); _loggerMock = new Mock <ILogger>(); _uut = new FavoritesController( _favoritesQueryMock.Object, _vendorsQueryMock.Object, _loggerMock.Object); }
private void BindCollectionToView() { if (FavoritesController.IsDataLoaded()) { ListQuotes.ItemsSource = FavoritesController.FavoritesCollection; } if (FavoritesController.HasItems()) { NoContentView.Visibility = Visibility.Collapsed; ListQuotes.Visibility = Visibility.Visible; } }
private void ItemSwipeTriggerInTouch(object sender, LLM.SwipeTriggerEventArgs args) { var quote = (sender as LLM.LLMListViewItem).Content as Quote; if (args.SwipeDirection == LLM.SwipeDirection.Left) { quote.IsShared = args.IsTrigger; } else { quote.IsFavorite = FavoritesController.IsFavorite(quote) ? !args.IsTrigger : args.IsTrigger; } }
private void CheckEmptyView() { if (FavoritesController.HasItems()) { NoContentView.Visibility = Visibility.Collapsed; ListQuotes.Visibility = Visibility.Visible; } else { NoContentView.Visibility = Visibility.Visible; ListQuotes.Visibility = Visibility.Collapsed; } }
public void Constructor_Should_ReturnCorrect_FavoritesController_Instance_WhenParametersPassed() { // Arrange var userServiceMock = new Mock <IUserService>(); var detailsServiceMock = new Mock <IDetailsService>(); var favServiceMock = new Mock <IFavoriteService>(); // Act var controllerUT = new FavoritesController(userServiceMock.Object, detailsServiceMock.Object, favServiceMock.Object); // Assert Assert.IsNotNull(controllerUT); }
public void BuilderInWorldToggleFavorite() { BuilderInWorldTestHelper.CreateTestCatalogLocalSingleObject(); CatalogItem item = DataStore.i.builderInWorld.catalogItemDict.GetValues()[0]; FavoritesController favoritesController = new FavoritesController(new GameObject("_FavoritesController").AddComponent <CatalogGroupListView>()); favoritesController.ToggleFavoriteState(item, null); Assert.IsTrue(item.IsFavorite()); favoritesController.ToggleFavoriteState(item, null); Assert.IsFalse(item.IsFavorite()); }
private void BindCollectionToFavoritesView() { if (FavoritesController.IsDataLoaded() && FavoritesController.FavoritesCollection.Count > 0) { ListView favoritesList = Controller.FindChildControl <ListView>(FavoritesSection, "FavoritesQuotes") as ListView; StackPanel NoContentFavoritesView = Controller.FindChildControl <StackPanel>(FavoritesSection, "NoContentFavoritesView") as StackPanel; favoritesList.ItemsSource = FavoritesController.FavoritesCollection; favoritesList.Visibility = Visibility.Visible; NoContentFavoritesView.Visibility = Visibility.Collapsed; } }
public void GetFavorites_ReturnsCorrectFoodItems() { // ARRANGE // Create the controller mocked with identity: FavoritesController controller = NewController(); // ACT IEnumerable <Food> foods = controller.GetFavorites(); // ASSERT Food food = foods.First(); Assert.AreEqual(600, food.Calories); }
public void Initialize(ISceneCatalogView sceneCatalogView, IQuickBarController quickBarController) { this.sceneCatalogView = sceneCatalogView; this.quickBarController = quickBarController; favoritesController = new FavoritesController(sceneCatalogView.catalogGroupList); biwSearchBarController = new BIWSearchBarController(); biwSearchBarController.Initialize(sceneCatalogView); sceneCatalogView.OnHideCatalogClicked += HideCatalogClicked; if (sceneCatalogView.catalogAssetPackList != null) { sceneCatalogView.catalogAssetPackList.OnCatalogPackClick += OnCatalogItemPackSelected; } if (sceneCatalogView.catalogGroupList != null) { sceneCatalogView.catalogGroupList.OnCatalogItemClicked += CatalogItemSelected; sceneCatalogView.catalogGroupList.OnResumeInput += ResumeInput; sceneCatalogView.catalogGroupList.OnStopInput += StopInput; sceneCatalogView.catalogGroupList.OnPointerEnterInAdapter += OnPointerEnter; sceneCatalogView.catalogGroupList.OnPointerExitInAdapter += OnPointerExit; } if (sceneCatalogView.category != null) { sceneCatalogView.category.onValueChanged.AddListener(CategoryFilter); } if (sceneCatalogView.favorites != null) { sceneCatalogView.favorites.onValueChanged.AddListener(FavoritesFilter); } if (sceneCatalogView.assetPack != null) { sceneCatalogView.assetPack.onValueChanged.AddListener(AssetsPackFilter); } sceneCatalogView.OnSceneCatalogBack += SceneCatalogBack; quickBarController.OnQuickBarShortcutSelected += QuickBarInput; quickBarController.OnCatalogItemSelected += CatalogItemSelected; biwSearchBarController.OnFilterChange += AssetsFiltered; biwSearchBarController.OnFilterRemove += FilterRemoved; }
public void GetFavorites_ReturnsCorrectFoodItems() { // ARRANGE // Create the controller mocked with identity: FavoritesController controller = NewController(); // ACT IEnumerable <Food> foods = controller.GetFavorites(); // ASSERT // The new profile username is correctly returned from the database Food food = foods.First(); Assert.AreEqual(600, food.Calories); }
private void Start() { quickBarController = new QuickBarController(quickBarView); favoritesController = new FavoritesController(catalogGroupListView); quickBarView.OnQuickBarShortcutSelected += QuickBarInput; catalogAssetPackListView.OnCatalogPackClick += OnCatalogItemPackSelected; catalogGroupListView.OnCatalogItemClicked += CatalogItemSelected; searchInputField.onValueChanged.AddListener(OnSearchInputChanged); quickBarController.OnCatalogItemSelected += CatalogItemSelected; categoryToggle.onValueChanged.AddListener(CategoryFilter); favoritesToggle.onValueChanged.AddListener(FavoritesFilter); assetPackToggle.onValueChanged.AddListener(AssetsPackFilter); }
public void Initialize(ISceneCatalogView sceneCatalogView, IQuickBarController quickBarController) { this.sceneCatalogView = sceneCatalogView; this.quickBarController = quickBarController; favoritesController = new FavoritesController(sceneCatalogView.catalogGroupList); sceneCatalogView.OnHideCatalogClicked += HideCatalogClicked; if (sceneCatalogView.catalogAssetPackList != null) { sceneCatalogView.catalogAssetPackList.OnCatalogPackClick += OnCatalogItemPackSelected; } if (sceneCatalogView.catalogGroupList != null) { sceneCatalogView.catalogGroupList.OnCatalogItemClicked += CatalogItemSelected; sceneCatalogView.catalogGroupList.OnResumeInput += ResumeInput; sceneCatalogView.catalogGroupList.OnStopInput += StopInput; } if (sceneCatalogView.searchInput != null) { sceneCatalogView.searchInput.onValueChanged.AddListener(OnSearchInputChanged); } if (sceneCatalogView.category != null) { sceneCatalogView.category.onValueChanged.AddListener(CategoryFilter); } if (sceneCatalogView.favorites != null) { sceneCatalogView.favorites.onValueChanged.AddListener(FavoritesFilter); } if (sceneCatalogView.assetPack != null) { sceneCatalogView.assetPack.onValueChanged.AddListener(AssetsPackFilter); } sceneCatalogView.OnSceneCatalogBack += SceneCatalogBack; quickBarController.OnQuickBarShortcutSelected += QuickBarInput; quickBarController.OnCatalogItemSelected += CatalogItemSelected; }
public FavoritesControllerTests() { var service = new Mock <IFavoritesService>(); var validationService = new Mock <IFavoritesValidationService>(); var discountValidationService = new Mock <IDiscountValidationService>(); _controller = new FavoritesController(service.Object, validationService.Object, discountValidationService.Object); _data = new List <FavoritesDto>(); _dataCreateUpdate = new List <FavoritesShortDto>(); InitTestData(); service.Setup(s => s.CreateAsync(It.IsAny <FavoritesShortDto>())) .Callback((FavoritesShortDto item) => { _dataCreateUpdate.Add(item); }) .Returns(Task.CompletedTask); service.Setup(s => s.UpdateAsync(It.IsAny <FavoritesShortDto>())) .Callback((FavoritesShortDto item) => { var oldItem = _dataCreateUpdate.Single(); if (oldItem != null) { _dataCreateUpdate.Remove(oldItem); _dataCreateUpdate.Add(item); } }) .Returns(Task.CompletedTask); service.Setup(s => s.RemoveAsync(It.IsAny <Guid>())) .Callback((Guid id) => { _data.RemoveAll(d => d.Id == id); }) .Returns(Task.CompletedTask); discountValidationService.Setup(v => v.DiscountExists(It.IsAny <Guid>(), default)) .Returns((Guid id, CancellationToken token) => Task.FromResult(_data.FirstOrDefault(d => d.Id == id) != null)); validationService.Setup(v => v.UserFavoritesNotExists(It.IsAny <Guid>(), default)) .Returns((Guid id, CancellationToken token) => Task.FromResult(_data.FirstOrDefault(d => d.Id == id) != null)); }
private void ToggleFavorite() { if (!IsSavedGallery) { return; } Favorite = !Favorite; if (Favorite) { if (!FavoritesController.FavoriteMd5s.Contains(Md5)) { FavoritesController.Favorites.Insert(0, this); } } else { FavoritesController.Favorites.RemoveAll(f => f.Md5 == Md5 || f.Link == Link); } FavoritesController.Save(); }
private async void AppStartup(object sender, StartupEventArgs args) { if (!Debugger.IsAttached) { ExceptionHandler.AddGlobalHandlers(); } HistoryController.Load(); SettingsController.Load(); FavoritesController.Load(); await Task.Delay(200); var mainWindow = new MainWindow { DataContext = new MainWindowViewModel() }; mainWindow.Show(); }
public override bool IsFavorite(Quote quote) { return(FavoritesController.IsFavorite(quote)); }
private async void PopulateFavoritesQuote() { await FavoritesController.Initialize(); BindCollectionToFavoritesView(); }
public void Setup() { context = TestUtils.GetMockContext(); controller = new FavoritesController(context); }