Example #1
0
        public async Task GetPersonsTest()
        {
            await base.SignIn(Role.User);

            var    dbContext        = TestsBase.CreateDbContext();
            Person testPersonEntity = new()
            {
                Id                   = Guid.NewGuid().ToString(),
                Name                 = "Test Name",
                PersonId             = 1,
                SampleFaceId         = Guid.NewGuid().ToString(),
                SampleFaceState      = "ok",
                SampleFaceUrl        = "http://wwww.test.local",
                SampleFaceSourceType = "video"
            };
            await dbContext.Person.AddAsync(testPersonEntity);

            await dbContext.SaveChangesAsync();

            VideoClientService videoClientService = base.CreateVideoClientService();
            var result = await videoClientService.GetPersonsAsync();

            /*
             * There could be more than 1 since Background Service might have already retrieve
             * persons from Azure Video Indexer API
             */
            var insertedPerson = result.SingleOrDefault(p => p.SampleFaceId == testPersonEntity.SampleFaceId);

            Assert.IsNotNull(insertedPerson);
        }
Example #2
0
        public async Task GetPublicProcessedVideosTest()
        {
            var authorizedHttpClient = await base.SignIn(Role.User);

            VideoClientService videoClientService = base.CreateVideoClientService();
            var dbContext = TestsBase.CreateDbContext();
            var videos    = await dbContext.VideoInfo.ToListAsync();

            var userEntity = await dbContext.ApplicationUser.Where(p => p.AzureAdB2cobjectId.ToString() ==
                                                                   TestsBase.TestAzureAdB2CAuthConfiguration !.AzureAdUserObjectId).SingleAsync();

            var testVideoEntity = CreateTestVideoEntity();

            testVideoEntity.VideoIndexStatusId = (short)Common.Global.Enums.VideoIndexStatus.Processed;
            testVideoEntity.VideoVisibilityId  = (short)Common.Global.Enums.VideoVisibility.Public;
            testVideoEntity.ApplicationUserId  = userEntity.ApplicationUserId;
            await dbContext.VideoInfo.AddAsync(testVideoEntity);

            await dbContext.SaveChangesAsync();

            PageRequestModel pageRequestModel = new() { PageNumber = 1 };
            var result = await videoClientService
                         .GetPublicProcessedVideosAsync(pageRequestModel);

            Assert.AreEqual(1, result.TotalItems);
        }
Example #3
0
        public async Task ListAllKeywordsTest()
        {
            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();

            await dbContext.VideoIndexKeyword.AddAsync(new VideoIndexKeyword()
            {
                Keyword     = "TestKeyword",
                VideoInfoId = testVideoEntity.VideoInfoId
            });

            await dbContext.SaveChangesAsync();

            var result = await videoClientService.ListAllKeywordsAsync();

            Assert.IsTrue(result !.Length == 1, "Invalid count of keywords");
        }
 protected override async Task OnInitializedAsync()
 {
     try
     {
         IsLoading = true;
         this.MyPendingVideosQueue = await VideoClientService.GetMyPendingVideosQueueAsync();
     }
     catch (Exception ex)
     {
         this.ToastifyService.DisplayErrorNotification(ex.Message);
     }
     finally
     {
         IsLoading = false;
     }
 }
        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);
        }
    }
}
Example #6
0
        public async Task BuyVideoAccessTest()
        {
            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();

            userEntity.AvailableFunds = 25;
            await dbContext.SaveChangesAsync();

            var testVideoEntity = CreateTestVideoEntity();

            testVideoEntity.ApplicationUserId = userEntity.ApplicationUserId;
            await dbContext.VideoInfo.AddAsync(testVideoEntity);

            await dbContext.SaveChangesAsync();

            await videoClientService.BuyVideoAccessAsync(testVideoEntity.VideoId);
        }
Example #7
0
        public async Task GetMyProcessedVideosTest()
        {
            var authorizedHttpClient = await base.SignIn(Role.User);

            VideoClientService videoClientService = base.CreateVideoClientService();
            var dbContext = TestsBase.CreateDbContext();
            var videos    = await dbContext.VideoInfo.ToListAsync();

            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();

            var result = await videoClientService.GetMyProcessedVideosAsync();

            Assert.AreEqual(1, result !.Length, "Invalid count of owned videos for test user");
        }
Example #8
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                IsLoading = true;
                ShowAvailableJobsButton      = FeatureClientService.IsFeatureEnabled(FeatureType.VideoJobSystem);
                this.NewCommentModel.VideoId = this.VideoId;
                string baseUrl        = this.NavigationManager.BaseUri;
                var    ogThumbnailurl = Constants.ApiRoutes.OpenGraphController.VideoThumbnail.Replace("{videoId}", this.VideoId);
                this.VideoThumbnailUrl = $"{baseUrl}{ogThumbnailurl}";
                this.VideoModel        = await this.VideoClientService.GetVideoAsync(VideoId);
                await LoadComments();

                if (AuthenticationStateTask is not null)
                {
                    var state = await AuthenticationStateTask;
                    if (state is not null && state.User is not null && state.User.Identity.IsAuthenticated)
                    {
                        var myVideos = await VideoClientService.GetMyProcessedVideosAsync();

                        if (myVideos.Any(p => p.VideoId == this.VideoId) &&
                            FeatureClientService.IsFeatureEnabled(FeatureType.VideoJobSystem))
                        {
                            //Logged in user is current video's owner
                            ShowAddVideoJobButton = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ToastifyService.DisplayErrorNotification(ex.Message);
            }
            finally
            {
                IsLoading = false;
            }
        }
Example #9
0
        public async Task GetMyPendingVideosQueueTest()
        {
            var authorizedHttpClient = await base.SignIn(Role.User);

            VideoClientService videoClientService = base.CreateVideoClientService();
            var dbContext = TestsBase.CreateDbContext();
            var videos    = await dbContext.VideoInfo.ToListAsync();

            var userEntity = await dbContext.ApplicationUser.Where(p => p.AzureAdB2cobjectId.ToString() ==
                                                                   TestsBase.TestAzureAdB2CAuthConfiguration !.AzureAdUserObjectId).SingleAsync();

            var testVideoEntity = CreateTestVideoEntity();

            testVideoEntity.VideoIndexStatusId = (short)Common.Global.Enums.VideoIndexStatus.Pending;
            testVideoEntity.ApplicationUserId  = userEntity.ApplicationUserId;
            await dbContext.VideoInfo.AddAsync(testVideoEntity);

            await dbContext.SaveChangesAsync();

            var result = await videoClientService.GetMyPendingVideosQueueAsync();

            Assert.AreEqual(1, result.Count);
        }
 /// <summary>
 /// Initializes <see cref="VideoEditAccessTokenProvider"/>
 /// </summary>
 /// <param name="videoClientService"></param>
 public VideoEditAccessTokenProvider(VideoClientService videoClientService)
 {
     this.VideoClientService = videoClientService;
 }