Esempio n. 1
0
 public EFUnitOfWork(PGDbContext context)
 {
     ClienteServicioEF         = new ClienteServicioEF(context);
     ClienteProductoServicioEF = new ClienteProductoServicioEF(context);
     DeudasServicioEF          = new DeudasServicioEF(context);
     UsuarioServicioEF         = new UsuarioServicioEF(context);
 }
Esempio n. 2
0
        public async Task CreateCorrectly()
        {
            var options = Utils.GetOptions(nameof(CreateCorrectly));

            var playlist = new PlaylistDTO
            {
                Title    = "In Utero",
                Duration = 1600,
                //PixabayImage = "https://en.wikipedia.org/wiki/In_Utero_(album)#/media/File:In_Utero_(Nirvana)_album_cover.jpg",
            };

            using (var arrangeContext = new PGDbContext(options))
            {
                var sut = new PlaylistService(arrangeContext);
                await sut.Create(playlist);

                await arrangeContext.SaveChangesAsync();
            }

            using (var assertContext = new PGDbContext(options))
            {
                var result = await assertContext.Playlists.FirstOrDefaultAsync(x => x.Title == playlist.Title);

                Assert.AreEqual(playlist.Title, result.Title);
                Assert.AreEqual(playlist.Duration, result.Duration);
                //Assert.AreEqual(playlist.PixabayImage, result.Picture);
            }
        }
Esempio n. 3
0
 public ActionResult GetData()
 {
     using (PGDbContext db = new PGDbContext())
     {
         List <Customer> customerList = db.Customers.ToList <Customer>();
         return(Json(new { data = customerList }, JsonRequestBehavior.AllowGet));
     }
 }
        public async Task GetAllPlaylistsByUserCorrectly()
        {
            var options = Utils.GetOptions(nameof(GetAllPlaylistsByUserCorrectly));

            var nirvanaPlaylist = new PlaylistDTO
            {
                Title    = "In Utero",
                Duration = 1600,
                //PixabayImage = "https://en.wikipedia.org/wiki/In_Utero_(album)#/media/File:In_Utero_(Nirvana)_album_cover.jpg",
                UserId = "153a257-526504u",
            };

            var acdcPlaylist = new PlaylistDTO
            {
                Title    = "Back in Black",
                Duration = 2531,
                //PixabayImage = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/92/ACDC_Back_in_Black.png/220px-ACDC_Back_in_Black.png",
                UserId = "153a257-526504u",
            };

            var scorpionsPLaylist = new PlaylistDTO
            {
                Title    = "Lovedrive",
                Duration = 2190,
                //PixabayImage = "https://en.wikipedia.org/wiki/Lovedrive#/media/File:Scorpions-album-lovedrive.jpg",
                UserId = "68910y78a-89as1568",
            };

            using (var arrangeContext = new PGDbContext(options))
            {
                var sut = new PlaylistService(arrangeContext);

                await sut.Create(nirvanaPlaylist);

                await sut.Create(acdcPlaylist);

                await sut.Create(scorpionsPLaylist);

                await arrangeContext.SaveChangesAsync();
            }

            using (var assertContext = new PGDbContext(options))
            {
                var sut = new PlaylistService(assertContext);

                var firstUserPalylists = await sut.GetPlaylistsByUser("153a257-526504u");

                int firstUserPalylistsCount = firstUserPalylists.Count();

                var secondUserPalylists = await sut.GetPlaylistsByUser("68910y78a-89as1568");

                int secondUserPalylistsCount = secondUserPalylists.Count();

                Assert.AreEqual(2, firstUserPalylistsCount);
                Assert.AreEqual(1, secondUserPalylistsCount);
            }
        }
Esempio n. 5
0
 public HomeController(PGDbContext context, IDeezerAPIService apiService, IPlaylistService playlistService,
                       UserManager <User> userManager, SignInManager <User> signInManager,
                       RoleManager <IdentityRole> roleManager)
 {
     _context         = context;
     _apiService      = apiService;
     _playlistService = playlistService;
     _roleManager     = roleManager;
 }
Esempio n. 6
0
        public async Task CreateThrowsWhenNull()
        {
            var options = Utils.GetOptions(nameof(CreateThrowsWhenNull));

            var context = new PGDbContext(options);
            var sut     = new PlaylistService(context);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => sut.Create(null));
        }
Esempio n. 7
0
        public async Task GetPlaylistByIdThrowsWhenNotFound()//TODO: Може ли да се тества съобщението на exception?
        {
            var options = Utils.GetOptions(nameof(GetPlaylistByIdThrowsWhenNotFound));

            var assertContext = new PGDbContext(options);

            var sut = new PlaylistService(assertContext);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => sut.GetPlaylistById(1));
        }
        public async Task GetAllPlaylistsByUserCorrectlyReturnEmpty()
        {
            var options = Utils.GetOptions(nameof(GetAllPlaylistsByUserCorrectlyReturnEmpty));

            var assertContext = new PGDbContext(options);

            var sut = new PlaylistService(assertContext);

            var userPalylists = await sut.GetPlaylistsByUser("153a257-526504u");

            int userPalylistsCount = userPalylists.Count();

            Assert.AreEqual(0, userPalylistsCount);
        }
Esempio n. 9
0
        public async Task UpdateThrowsWhenNotFound()
        {
            var options = Utils.GetOptions(nameof(UpdateThrowsWhenNotFound));

            var acdcPlaylist = new PlaylistDTO
            {
                Title    = "Back in Black",
                Duration = 2531,
                //PixabayImage = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/92/ACDC_Back_in_Black.png/220px-ACDC_Back_in_Black.png",
            };

            var assertContext = new PGDbContext(options);

            var sut = new PlaylistService(assertContext);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => sut.Update(1, acdcPlaylist));
        }
Esempio n. 10
0
        public async Task CreateThrowsWhenNameAbove50Chars()
        {
            var options = Utils.GetOptions(nameof(CreateThrowsWhenNameAbove50Chars));


            var context = new PGDbContext(options);
            var sut     = new PlaylistService(context);

            var playlist = new PlaylistDTO
            {
                Title    = "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
                Duration = 1600,
                //PixabayImage = "https://en.wikipedia.org/wiki/In_Utero_(album)#/media/File:In_Utero_(Nirvana)_album_cover.jpg",
            };

            await Assert.ThrowsExceptionAsync <ArgumentOutOfRangeException>(() => sut.Create(playlist));
        }
Esempio n. 11
0
        public async Task GetPlaylistByIdCorrectly()
        {
            var options = Utils.GetOptions(nameof(GetPlaylistByIdCorrectly));

            var nirvanaPlaylist = new PlaylistDTO
            {
                Title    = "In Utero",
                Duration = 1600,
                //PixabayImage = "https://en.wikipedia.org/wiki/In_Utero_(album)#/media/File:In_Utero_(Nirvana)_album_cover.jpg",
            };

            var acdcPlaylist = new PlaylistDTO
            {
                Title    = "Back in Black",
                Duration = 2531,
                //PixabayImage = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/92/ACDC_Back_in_Black.png/220px-ACDC_Back_in_Black.png",
            };

            using (var arrangeContext = new PGDbContext(options))
            {
                var sut = new PlaylistService(arrangeContext);

                await sut.Create(nirvanaPlaylist);

                await sut.Create(acdcPlaylist);

                await arrangeContext.SaveChangesAsync();
            }

            using (var assertContext = new PGDbContext(options))
            {
                var sut = new PlaylistService(assertContext);

                var userPalylists = await sut.GetPlaylistById(1);

                Assert.AreEqual(nirvanaPlaylist.Title, userPalylists.Title);
                Assert.AreEqual(nirvanaPlaylist.Duration, userPalylists.Duration);
                Assert.AreEqual(nirvanaPlaylist.PixabayImage, userPalylists.PixabayImage);
            }
        }
Esempio n. 12
0
        public async Task GeneratePlaylistCorrectly()
        {
            var options = Utils.GetOptions(nameof(GeneratePlaylistCorrectly));

            int    timeForTrip      = 7200;
            string playlistTitle    = "Sofia - Sandanski";
            int    metalPercentagee = 25;
            int    rockPercentagee  = 25;
            int    popPercentagee   = 50;
            bool   topTracks        = true;
            bool   sameArtist       = true;
            User   user             = new User();

            var arrangeContext = new PGDbContext(options);

            var deezerService = new DeezerAPIService(arrangeContext);

            await deezerService.ExtractSongsFromPlaylists("pop");

            await deezerService.ExtractSongsFromPlaylists("rock");

            await deezerService.ExtractSongsFromPlaylists("metal");

            var sut = new PlaylistService(arrangeContext);

            await sut.GeneratePlaylist(timeForTrip, playlistTitle, metalPercentagee, rockPercentagee, popPercentagee, topTracks, sameArtist, user);

            await arrangeContext.SaveChangesAsync();

            var actual = arrangeContext.Playlists.FirstOrDefault(x => x.Id == 1);

            Assert.AreEqual(1, actual.Id);
            Assert.AreEqual(playlistTitle, actual.Title);
            Assert.AreEqual(user.Id, actual.UserId);
            Assert.IsTrue(actual.Duration < timeForTrip + 300);
            Assert.IsTrue(actual.Duration > timeForTrip - 300);
            Assert.IsTrue(actual.PlaylistsGenres.Count() == 3);
            Assert.IsTrue(actual.PlaylistsSongs.Count() != 0);
        }
Esempio n. 13
0
 public EndGameSessionsController(PGDbContext context)
 {
     this.context = context;
 }
Esempio n. 14
0
 public UsersService(PGDbContext context)
 {
     _context = context;
 }
Esempio n. 15
0
 public TaskService(PGDbContext context)
 {
     _context = context;
 }
Esempio n. 16
0
 public DeudasServicioEF(PGDbContext context)
 {
     _deudasEF = new DeudasRepositorioEF(context);
 }
Esempio n. 17
0
 public HomeController(PGDbContext context)
 {
     _context = context;
 }
 public PickupsController(PGDbContext context)
 {
     this.context = context;
 }
 public PickupsController()
 {
     context = new PGDbContext();
 }
Esempio n. 20
0
 public EventController()
 {
     _context = new PGDbContext();
 }
Esempio n. 21
0
 public ClienteServicioEF(PGDbContext context)
 {
     _clienteEF = new ClienteRepositorioEF(context);
 }
 public UsuarioRepositorioEF(PGDbContext context) : base(context)
 {
 }