Пример #1
0
        public void SearchByStartsWithAndOrder()
        {
            SqlLiteDatabaseTest(options =>
            {
                var audioService = _server.Host.Services.GetService(typeof(IAudioService)) as IAudioService;

                using (var context = new PlayCatDbContext(options))
                {
                    audioService.SetDbContext(context);

                    context.CreateAudio(DateTime.Now, "0", artist: "B", song: "B", extension: "", filename: "", videoId: "A", uploaderId: null);
                    context.CreateAudio(DateTime.Now, "1", artist: "B", song: "A", extension: "", filename: "", videoId: "B", uploaderId: null);
                    context.CreateAudio(DateTime.Now, "2", artist: "A", song: "B", extension: "", filename: "", videoId: "C", uploaderId: null);

                    context.SaveChanges();

                    var result = audioService.SearchAudios("A", 0, 10);

                    CheckIfSuccess(result);
                    Assert.Equal(result.Audios.Count(), 3);
                    Assert.Equal(result.Audios.ElementAt(0).AccessUrl, "0");
                    Assert.Equal(result.Audios.ElementAt(1).AccessUrl, "1");
                    Assert.Equal(result.Audios.ElementAt(2).AccessUrl, "2");
                }
            });
        }
Пример #2
0
        private void CreateAndAddAudio(PlayCatDbContext context, Guid playlistId, int count)
        {
            if (count < -0)
            {
                return;
            }

            for (int i = 0; i < count; i++)
            {
                DataModel.Audio audio = context.CreateAudio(DateTime.Now.AddMinutes(i), "access" + i, "artist" + i, "song" + i, BaseAudioExtension, i.ToString(), i.ToString(), null);

                DataModel.AudioPlaylist audioPlaylist = context.CreateAudioPlaylist(DateTime.Now.AddMinutes(i), audio.Id, playlistId, i);
            }
        }
Пример #3
0
        public void SearchByComposeArtistAndSong()
        {
            SqlLiteDatabaseTest(options =>
            {
                var audioService = _server.Host.Services.GetService(typeof(IAudioService)) as IAudioService;

                using (var context = new PlayCatDbContext(options))
                {
                    audioService.SetDbContext(context);

                    context.CreateAudio(DateTime.Now, "0", artist: "A", song: "B", extension: "", filename: "", videoId: "", uploaderId: null);
                    context.SaveChanges();

                    var result = audioService.SearchAudios("A B", 0, 10);

                    CheckIfSuccess(result);
                    Assert.Equal(result.Audios.Count(), 1);
                }
            });
        }