public async Task DeleteVideoPlaylistTest() { var authorizedHttpClient = await base.SignIn(Role.User); var dbContext = TestsBase.CreateDbContext(); VideoPlaylistModel testVideoPlaylist = CreateTestVideoPlaylist(); VideoPlaylistClientService videoPlaylistClientService = base.CreateVideoPlaylistClientService(); await videoPlaylistClientService.CreateVideoPlaylistAsync(testVideoPlaylist); var entity = await dbContext.VideoPlaylist .Include(p => p.OwnerApplicationUser) .Where(p => p.PlaylistName == testVideoPlaylist.PlaylistName && p.OwnerApplicationUser.AzureAdB2cobjectId.ToString() == TestsBase.TestAzureAdB2CAuthConfiguration !.AzureAdUserObjectId) .AsNoTracking().SingleOrDefaultAsync(); Assert.IsNotNull(entity); await videoPlaylistClientService.DeleteVideoPlaylistAsync(entity !.VideoPlaylistId); entity = await dbContext.VideoPlaylist .Include(p => p.OwnerApplicationUser) .Where(p => p.PlaylistName == testVideoPlaylist.PlaylistName && p.OwnerApplicationUser.AzureAdB2cobjectId.ToString() == TestsBase.TestAzureAdB2CAuthConfiguration !.AzureAdUserObjectId) .AsNoTracking().SingleOrDefaultAsync(); Assert.IsNull(entity); }
public async Task AddVideoToPlaylistTest() { await base.SignIn(Role.User); VideoClientService videoClientService = base.CreateVideoClientService(); var dbContext = TestsBase.CreateDbContext(); var userEntity = await dbContext.ApplicationUser.Where(p => p.AzureAdB2cobjectId.ToString() == TestsBase.TestAzureAdB2CAuthConfiguration !.AzureAdUserObjectId).SingleAsync(); var testVideoEntity = CreateTestVideoEntity(); testVideoEntity.ApplicationUserId = userEntity.ApplicationUserId; await dbContext.VideoInfo.AddAsync(testVideoEntity); await dbContext.SaveChangesAsync(); VideoPlaylist testVideoPlaylist = new() { PlaylistDescription = "Test Desc", PlaylistName = "Test Name", OwnerApplicationUserId = userEntity.ApplicationUserId }; await dbContext.VideoPlaylist.AddAsync(testVideoPlaylist); await dbContext.SaveChangesAsync(); VideoPlaylistItemModel videoPlaylistItemModel = new() { VideoPlaylistId = testVideoPlaylist.VideoPlaylistId, VideoId = testVideoEntity.VideoId, Order = 1 }; VideoPlaylistClientService videoPlaylistClientService = base.CreateVideoPlaylistClientService(); await videoPlaylistClientService.AddVideoToPlaylistAsync(videoPlaylistItemModel); var result = await dbContext.VideoPlaylistItem.SingleOrDefaultAsync(p => p.VideoInfoId == testVideoEntity.VideoInfoId); Assert.IsNotNull(result); } } }