예제 #1
0
        public MusicLibraryTests()
        {
            _mockDataLoader        = new LibraryDbMockGenerator();
            _musicLibraryDbContext = _mockDataLoader.DbContextMock;

            var settings      = A.Fake <IDukeboxSettings>();
            var albumArtCache = A.Fake <IAlbumArtCacheService>();
            var audioFormats  = new AudioFileFormats();

            A.CallTo(() => settings.AddDirectoryConcurrencyLimit).Returns(20);

            audioFormats.SupportedFormats.Add(".mp3");

            _musicLibrary = new MusicLibrary(_musicLibraryDbContext, settings, albumArtCache, audioFormats);
        }
예제 #2
0
        public MusicLibrary(IMusicLibraryDbContext libraryDbContext, IDukeboxSettings settings,
                            IAlbumArtCacheService albumArtCache, AudioFileFormats audioFormats)
        {
            _dukeboxData = libraryDbContext;

            _settings      = settings;
            _audioFormats  = audioFormats;
            _albumArtCache = albumArtCache;

            RecentlyPlayed = new ObservableCollection <ITrack>();
            RecentlyPlayed.CollectionChanged += RecentlyPlayedChangedHander;

            _dbContextMutex = new SemaphoreSlim(1, 1);
            _searchService  = new MusicLibrarySearchService(libraryDbContext, this, _dbContextMutex);

            _allFilesCache = _dukeboxData.Songs.Select(s => s.FileName).ToList();
        }
예제 #3
0
        public LibraryDbMockGenerator(bool overrideLibraryPackage = true)
        {
            DbContextMock = A.Fake <IMusicLibraryDbContext>();

            if (overrideLibraryPackage && !containerModified)
            {
                LibraryPackage.ExecutingForUnitTests = true;
                var libraryContainer = LibraryPackage.GetContainerForTestOverrides();

                libraryContainer.Options.AllowOverridingRegistrations = true;
                libraryContainer.RegisterSingleton <IMusicLibraryDbContext>(DbContextMock);

                containerModified = true;
            }

            Songs = new List <Song>();

            var songId = 0;

            Artists.ForEach(artist =>
            {
                Albums.ForEach(album =>
                {
                    Songs.Add(new Song
                    {
                        Id              = songId,
                        FileName        = Mp3FilePath,
                        Title           = "wish you were here",
                        LengthInSeconds = 120,
                        AlbumId         = album.Id,
                        ArtistId        = artist.Id
                    });

                    songId++;
                });
            });

            WireUpMockData();
        }
예제 #4
0
 public MusicLibrarySearchService(IMusicLibraryDbContext dukeboxData, IMusicLibrary musicLibrary, SemaphoreSlim dbContextMutex)
 {
     _dukeboxData    = dukeboxData;
     _musicLibrary   = musicLibrary;
     _dbContextMutex = dbContextMutex;
 }