public ProductsCountNavbarViewComponent( IFavouritesService favouritesService, IShoppingCartService shoppingCartService) { this.favouritesService = favouritesService; this.shoppingCartService = shoppingCartService; }
public async Task RemoveFromFavoritesAsync_WithoutVideoInTheFavoritesList_ShouldThrowAndInvalidOperationException() { //Arrange var expectedErrorMessage = "The given video isn't in the favorites list!"; var option = new DbContextOptionsBuilder <ChessDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var db = new ChessDbContext(option); var moqUserService = new Mock <IUsersService>(); moqUserService.Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(new ApplicationUser { Id = "UserId", UserName = "******", }); favouritesService = new FavouritesService(db, moqUserService.Object); var testingVideo = new Video { Id = 2, Title = "VideoTitle", }; await db.Videos.AddAsync(testingVideo); await db.SaveChangesAsync(); //Act and assert var ex = await Assert.ThrowsAsync <InvalidOperationException>(() => favouritesService.RemoveFromFavoritesAsync(2)); Assert.Equal(expectedErrorMessage, ex.Message); }
public UsersController(UserManager <User> userManager, IMessageServices messageService, IUserServices userServices, IFavouritesService favouritesService, IMovieServices movieServices) { this.userManager = userManager; this.messageService = messageService; this.userServices = userServices; this.favouritesService = favouritesService; this.movieServices = movieServices; }
public MomentsController(IMomentsService momentsService, IUserUploadsService userUploadsService, IUserLanguageService userLangService, ILanguageService langService, IFavouritesService favService) { _momentsService = momentsService; _userUploadsService = userUploadsService; _userLangService = userLangService; _langService = langService; _favService = favService; }
public AccountController(IUserService userService, IUserLanguageService userLanguageService, ILanguageService langService, IFavouritesService favService, IUserFollowDetailService userFollowDetailService, ICountryService countryService) { _userService = userService; _userLanguageService = userLanguageService; _langService = langService; _favService = favService; _userFollowDetailService = userFollowDetailService; _countryService = countryService; }
public MoviesController(IAddMovieService addMovieService, IMovieServices movieServices, IActorServices actorServices, IGenreServices genreServices, ITheMovieDbClient client, IJsonProvider jsonProvider, IFavouritesService favouritesService, UserManager <User> userManager) { this.client = client; this.jsonProvider = jsonProvider; this.favouritesService = favouritesService; this.userManager = userManager; this.addMovieService = addMovieService; this.movieService = movieServices; this.actorServices = actorServices; this.genresServices = genreServices; }
public FavouritesController(IFavouritesService favService, IUserFollowDetailService userFollowService, IBlockService blockservice, IUserTransliterationService transliterationService, ITransliterationService transService, IMomentsService momentsService, IUserUploadsService userUploadsService, ICountryService countryService) { _favService = favService; _userFollowService = userFollowService; _blockservice = blockservice; _transliterationService = transliterationService; _transService = transService; _momentsService = momentsService; _userUploadsService = userUploadsService; _countryService = countryService; }
public async Task AddToFavoritesAsync_WithCurrentUserEqualsToNull_ShouldThrowAndInvalidOperationException() { //Arrange var expectedErrorMessage = "Current user can't be null"; var option = new DbContextOptionsBuilder <ChessDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var db = new ChessDbContext(option); var moqUserService = new Mock <IUsersService>(); this.favouritesService = new FavouritesService(db, moqUserService.Object); //Act and assert var ex = await Assert.ThrowsAsync <InvalidOperationException>(() => this.favouritesService.AddToFavoritesAsync(1)); Assert.Equal(expectedErrorMessage, ex.Message); }
public MyDeezerDataController(IDeezerSession session, IAuthenticationService authService, IFavouritesService favouritesService) { this.session = session; this.authService = authService; this.favouritesService = favouritesService; this.trackFetchState = new UpdatableFetchState(); this.albumsFetchState = new UpdatableFetchState(); this.artistFetchState = new UpdatableFetchState(); this.favouriteTracks = new PagedObservableCollection <ITrackViewModel>(); this.favouriteAlbums = new PagedObservableCollection <IAlbumViewModel>(); this.favouriteArtists = new PagedObservableCollection <IArtistViewModel>(); this.authService.OnAuthenticationStatusChanged += OnAuthenticationStateChanged; this.favouritesService.OnFavouritesChanged += OnFavouritesChanged; }
public async Task AddToFavoritesAsync_WithVideoAlreadyInFavorites_ShouldThrowAnInvalidOperationException() { //Arrange var expectedErrorMessage = "The given video is already added to favorites!"; var option = new DbContextOptionsBuilder <ChessDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var db = new ChessDbContext(option); var moqUserService = new Mock <IUsersService>(); moqUserService.Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(new ApplicationUser { Id = "UserId", UserName = "******", UserFavouriteVideos = new List <UserFavouriteVideo> { new UserFavouriteVideo { Id = 1, VideoId = 2, }, } }); this.favouritesService = new FavouritesService(db, moqUserService.Object); var testingVideo = new Video { Id = 2, Title = "VideoTitle", }; await db.Videos.AddAsync(testingVideo); await db.SaveChangesAsync(); //Act and assert var ex = await Assert.ThrowsAsync <InvalidOperationException>(() => this.favouritesService.AddToFavoritesAsync(2)); Assert.Equal(expectedErrorMessage, ex.Message); }
public async Task RemoveFromFavoritesAsync_WithExistingVideoInFavorites_ShouldReturnTrue() { //Arrange var option = new DbContextOptionsBuilder <ChessDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var db = new ChessDbContext(option); var moqUserService = new Mock <IUsersService>(); moqUserService.Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(new ApplicationUser { Id = "UserId", UserName = "******", UserFavouriteVideos = new List <UserFavouriteVideo> { new UserFavouriteVideo { Id = 1, VideoId = 2, }, } }); favouritesService = new FavouritesService(db, moqUserService.Object); var testingVideo = new Video { Id = 2, Title = "VideoTitle", }; await db.Videos.AddAsync(testingVideo); await db.UserFavouriteVideos.AddAsync(new UserFavouriteVideo { Id = 1, VideoId = 2, ApplicationUserId = "UserId" }); await db.SaveChangesAsync(); //Act var actual = await favouritesService.RemoveFromFavoritesAsync(2); //Assert Assert.True(actual); }
public ArtistOverviewViewModel(IPlatformServices platformServices, IArtistOverviewDataController dataController, IFavouritesService favouritesService, ArtistOverviewViewModelParams p) : base(platformServices) { this.dataController = dataController; this.favouritesService = favouritesService; this.albums = new MainThreadObservableCollectionAdapter <IAlbumViewModel>(this.dataController.Albums, PlatformServices.MainThreadDispatcher); this.topTracks = new MainThreadObservableCollectionAdapter <ITrackViewModel>(this.dataController.TopTracks, PlatformServices.MainThreadDispatcher); this.relatedArtists = new MainThreadObservableCollectionAdapter <IArtistViewModel>(this.dataController.RelatedArtists, PlatformServices.MainThreadDispatcher); this.featuredPlaylists = new MainThreadObservableCollectionAdapter <IPlaylistViewModel>(this.dataController.Playlists, PlatformServices.MainThreadDispatcher); // TODO: Default artwork for artist... // NEEDS to be done before the fetch status changed is added, as event will fire before we've set fallback this.ArtistId = p.ArtistId; this.ArtistImage = "ms-appx:///Assets/StoreLogo.png"; this.dataController.OnAlbumFetchStateChanged += OnAlbumFetchStateChanged; this.dataController.OnTopTrackFetchStateChanged += OnTopTrackFetchStateChanged; this.dataController.OnPlaylistFetchStateChanged += OnPlaylistFetchStateChanged; this.dataController.OnRelatedArtistFetchStateChanged += OnRelatedArtistFetchStateChanged; this.dataController.OnCompleteArtistFetchStateChanged += OnCompleteArtistFetchStateChanged; this.dataController.FetchOverviewAsync(this.ArtistId); UpdateFavouriteState(); this.favouritesService.OnFavouritesChanged += OnFavouritesChanged; }
public TracklistViewModel(IPlatformServices platformServices, ITracklistDataController dataController, IFavouritesService favouritesService, TracklistViewModelParams p) : base(platformServices) { this.dataController = dataController; this.favouritesService = favouritesService; this.tracklist = new MainThreadObservableCollectionAdapter <ITrackViewModel>(this.dataController.Tracklist, PlatformServices.MainThreadDispatcher); this.ItemId = p.ItemId; this.Type = p.Type; this.Title = string.Empty; this.Subtitle = string.Empty; this.ArtworkUri = "ms-appx://Assets/StoreLogo.png"; this.WebsiteLink = null; switch (this.Type) { case ETracklistViewModelType.Album: this.dataController.FetchTracklistAsync(ETracklistType.Album, this.ItemId); break; case ETracklistViewModelType.Playlist: this.dataController.FetchTracklistAsync(ETracklistType.Playlist, this.ItemId); break; } this.dataController.OnTracklistFetchStateChanged += OnFetchStateChanged; this.dataController.OnCompleteItemFetchStateChanged += OnHeaderFetchStateChanged; this.favouritesService.OnFavouritesChanged += OnFavouritesChanged; UpdateFavouriteState(); }
public async Task AddToFavoritesAsync_WithValidData_ShouldReturnTrue() { //Arrange var option = new DbContextOptionsBuilder <ChessDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var db = new ChessDbContext(option); var moqUserService = new Mock <IUsersService>(); moqUserService.Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(new ApplicationUser { Id = "UserId", UserName = "******" }); this.favouritesService = new FavouritesService(db, moqUserService.Object); var testingVideo = new Video { Id = 1, Title = "VideoTitle", }; await db.Videos.AddAsync(testingVideo); await db.SaveChangesAsync(); //Act var actual = await this.favouritesService.AddToFavoritesAsync(1); var userFavouriteVideo = db.UserFavouriteVideos.FirstOrDefaultAsync(x => x.VideoId == 1 && x.ApplicationUserId == "UserId"); //Assert Assert.True(actual); Assert.NotNull(userFavouriteVideo); }
public async Task AddToFavoritesAsync_WithInvalidVideoId_ShouldThrowAnArgumentException() { //Arrange var expectedErrorMessage = "Video with the given id doesn't exist!"; var option = new DbContextOptionsBuilder <ChessDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var db = new ChessDbContext(option); var moqUserService = new Mock <IUsersService>(); moqUserService.Setup(x => x.GetCurrentUserAsync()) .ReturnsAsync(new ApplicationUser { Id = Guid.NewGuid().ToString(), UserName = "******" }); this.favouritesService = new FavouritesService(db, moqUserService.Object); var ex = await Assert.ThrowsAsync <ArgumentException>(() => this.favouritesService.AddToFavoritesAsync(1)); Assert.Equal(expectedErrorMessage, ex.Message); }
public FavouritesController(IFavouritesService favouritesService) { this.favouritesService = favouritesService; }
public FavouritesSchedulingService(IFavouritesService favouritesService, IApiClientService apiClientService, ISTLogger logger) { _favouritesService = favouritesService; _apiClientService = apiClientService; _logger = logger; }
/// <summary> /// Constructor for Favourites functions of McKenzies Pharmacy API /// </summary> public FavouritesController(IFavouritesService service, ICustomersService customerService) { _service = service; _customerService = customerService; }
public UsersController(UserManager <ApplicationUser> userManager, IFavouritesService favouritesService) { this.userManager = userManager; this.favouritesService = favouritesService; }
public ProfileController(IReviewService reviewServices, IFavouritesService favouritesService, IUserServices userServices) { this.reviewServices = reviewServices; this.favouritesService = favouritesService; this.userServices = userServices; }