コード例 #1
0
            public static void CanAddTracksAsync_InaccessibleTrack_ReturnsFalse()
            {
                var dbConnection = OpenSqliteDatabase();

                var dbContextOptionsBuilder = new DbContextOptionsBuilder <MediaInfoContext>()
                                              .DisableClientSideEvaluation()
                                              .UseSqlite(dbConnection);

                using (var dbContext = new MediaInfoContext(dbContextOptionsBuilder.Options))
                {
                    var random    = new RandomPopulator(dbContext);
                    var user      = random.AddUser();
                    var library   = random.AddLibrary(accessControlled: true);
                    var artist    = random.AddArtist();
                    var album     = random.AddAlbum(artist);
                    var directory = random.AddDirectory(library);
                    var file      = random.AddFile(directory);
                    var track     = random.AddTrack(file, artist, album);
                    dbContext.SaveChanges();

                    int[] trackIds = new[] { track.TrackId };
                    bool  result   = RestApiQueries.CanAddTracksAsync(dbContext, user.UserId, trackIds, CancellationToken.None).GetAwaiter().GetResult();

                    Assert.False(result);
                }
            }
コード例 #2
0
            public static void CanAddTracksAsync_Empty_ReturnsTrue()
            {
                var dbConnection = OpenSqliteDatabase();

                var dbContextOptionsBuilder = new DbContextOptionsBuilder <MediaInfoContext>()
                                              .DisableClientSideEvaluation()
                                              .UseSqlite(dbConnection);

                using (var dbContext = new MediaInfoContext(dbContextOptionsBuilder.Options))
                {
                    var random = new RandomPopulator(dbContext);
                    var user   = random.AddUser();
                    dbContext.SaveChanges();

                    int[] trackIds = Array.Empty <int>();
                    bool  result   = RestApiQueries.CanAddTracksAsync(dbContext, user.UserId, trackIds, CancellationToken.None).GetAwaiter().GetResult();

                    Assert.True(result);
                }
            }