public async Task Should_ReturnNone_When_AnnotationHasNoReplies()
        {
            // Create a test user
            var userRequest = new CreateUserWithoutAuth("Alice");
            var user        = await _fixture.SendAsync(userRequest);

            const string title       = "My Fantastic Library";
            const string description = "A suitable description.";

            // User creates library
            var createLibraryRequest = new CreateLibrary(user.Id, title, description);
            await _fixture.SendAsync(createLibraryRequest);

            // Get libraries just created by user
            var getLibrariesRequest = new GetLibrariesForUser(user.Id);
            var libraries           = await _fixture.SendAsync(getLibrariesRequest);

            // Get id of the single library
            var libraryDtos = libraries.ToList();
            var libraryId   = libraryDtos.ElementAt(0).Id;

            // create video
            var vidTitle       = "Video title";
            var vidLink        = "Link goes here";
            var vidDescription = "Video description";

            var createVideoRequest = new CreateVideo(user.Id, libraryId, vidTitle, vidLink, vidDescription);
            await _fixture.SendAsync(createVideoRequest);

            // Get video
            var getVideosRequest = new GetVideosOfLibrary(libraryId);
            var videos           = await _fixture.SendAsync(getVideosRequest);

            var video = videos.ToList().ElementAt(0);

            // Create annotation
            var comment1   = "This is a comment!";
            var timestamp1 = 1.25;

            var annotationRequest1 = new CreateAnnotation(user.Id, comment1, video.Id, timestamp1);

            await _fixture.SendAsync(annotationRequest1);

            // get annotation
            var getAnnotationsRequest = new GetAnnotationsByVideoId(video.Id);
            var results = await _fixture.SendAsync(getAnnotationsRequest);

            var annotation = results.Single();

            // get replies
            var getAnnotationRepliesRequest = new GetAnnotationRepliesByAnnotationId(annotation.Id);
            var repliesResults = await _fixture.SendAsync(getAnnotationRepliesRequest);

            var replies = repliesResults.ToList();

            // Check that nothing got returned, since no replies were created
            Assert.Empty(replies);
        }
Beispiel #2
0
        public async Task ItRunsAndEditsVideos()
        {
            //const int libraryId = 1;
            const string title       = "My Fantastic Library";
            const string description = "A suitable description.";

            // Create a test user (don't think this is needed here)
            var userRequest = new CreateUserWithoutAuth("Alice");
            var user        = await _fixture.SendAsync(userRequest);

            // Create a library with that user
            var request = new CreateLibrary(user.Id, title, description);
            await _fixture.SendAsync(request);

            // Get all libraries created by that user
            var librariesRequest1 = new GetLibrariesForUser(user.Id);
            var libraries1        = (await _fixture.SendAsync(librariesRequest1)).ToArray();

            // Make sure there's only one library
            var libraryDtos = libraries1.ToList();

            Assert.Single(libraryDtos);

            // Get id of the single library
            var libraryId = libraryDtos.ToList().ElementAt(0).Id;

            // Create video for library
            const string vidTitle          = "Video Title";
            const string newVidTitle       = "My Fantastic New Video Title";
            const string videoUrl          = "https://www.youtube.com/watch?v=-O5kNPlUV7w";
            const string vidDescription    = "Video description";
            const string newVidDescription = "A (new) suitable video description.";

            var createVideosRequest1 = new CreateVideo(user.Id, libraryId, vidTitle, videoUrl, vidDescription);

            await _fixture.SendAsync(createVideosRequest1);

            // Get video for library
            var getVideoRequest = new GetVideosOfLibrary(libraryId);
            var video           = await _fixture.SendAsync(getVideoRequest);

            // Edit video with that user
            var videoId            = video.Single().Id;
            var updateVideoRequest = new UpdateVideoInfo(videoId, newVidTitle, newVidDescription);
            await _fixture.SendAsync(updateVideoRequest);

            // Get video created by that user
            var getVideoRequest1 = new GetVideosOfLibrary(libraryId);
            var video1           = await _fixture.SendAsync(getVideoRequest1);

            // Check that our video is the only video returned
            Assert.Single(video1);

            // Check that the fields match the fields we set
            Assert.Equal(newVidTitle, video1.Single().Title);
            Assert.Equal(newVidDescription, video1.Single().Description);
        }
Beispiel #3
0
        public async Task ItDeletesVideoFromLibrary()
        {
            // Create a test user
            var userRequest = new CreateUserWithoutAuth("Alice");
            var user        = await _fixture.SendAsync(userRequest);

            const string title       = "My Fantastic Library";
            const string description = "A suitable description.";

            // User creates library
            var createLibraryRequest = new CreateLibrary(user.Id, title, description);
            await _fixture.SendAsync(createLibraryRequest);

            // Get libraries just created by user
            var getLibrariesRequest = new GetLibrariesForUser(user.Id);
            var libraries           = await _fixture.SendAsync(getLibrariesRequest);

            // Make sure there's only one library
            var libraryDtos = libraries.ToList();

            Assert.Single(libraryDtos);

            // Get id of the single library
            var libraryId = libraryDtos.ToList().ElementAt(0).Id;

            // Create video for library
            const string vidTitle       = "Video Title";
            const string videoUrl       = "https://www.youtube.com/watch?v=-O5kNPlUV7w";
            const string vidDescription = "Video description";

            var createVideosRequest = new CreateVideo(user.Id, libraryId, vidTitle, videoUrl, vidDescription);
            await _fixture.SendAsync(createVideosRequest);

            // Get videos just created by user
            var getVideosRequest = new GetVideosOfLibrary(libraryId);
            var videos           = await _fixture.SendAsync(getVideosRequest);

            // Make sure there's only one video
            var videoDtos = videos.ToList();

            Assert.Single(videoDtos);

            var videoId = videoDtos.ToList().ElementAt(0).Id;

            //delete video from library
            var deleteVideoRequest = new DeleteVideoFromLibrary(videoId);
            await _fixture.SendAsync(deleteVideoRequest);

            // Check for any remaining videos (should be 0)
            var getVideosRequest1 = new GetVideosOfLibrary(libraryId);
            var videosLeft        = await _fixture.SendAsync(getVideosRequest1);

            var videoCount = videosLeft.Count();

            Assert.Equal(0, videoCount);
        }
Beispiel #4
0
        public async Task Should_ThrowInvalidOperationException_When_GivenInvalidId()
        {
            // Create a test user
            var userRequest = new CreateUserWithoutAuth("Alice");
            var user        = await _fixture.SendAsync(userRequest);

            const string title       = "My Fantastic Library";
            const string description = "A suitable description.";

            // User creates library
            var createLibraryRequest = new CreateLibrary(user.Id, title, description);
            await _fixture.SendAsync(createLibraryRequest);

            // Get libraries just created by user
            var getLibrariesRequest = new GetLibrariesForUser(user.Id);
            var libraries           = await _fixture.SendAsync(getLibrariesRequest);

            // Make sure there's only one library
            var libraryDtos = libraries.ToList();

            Assert.Single(libraryDtos);

            // Get id of the single library
            var libraryId = libraryDtos.ToList().ElementAt(0).Id;

            // Create two videos for library
            const string videoTitle       = "Video Title";
            const string videoUrl         = "https://www.youtube.com/watch?v=-O5kNPlUV7w";
            const string videoDescription = "Video Description";

            var createVideosRequest1 = new CreateVideo(user.Id, libraryId, videoTitle, videoUrl, videoDescription);

            await _fixture.SendAsync(createVideosRequest1);

            // Get videos for library
            var getVideosRequest = new GetVideosOfLibrary(libraryId);
            var videos           = await _fixture.SendAsync(getVideosRequest);

            // Make sure correct number of videos returned
            var videoDtos = videos.ToList();

            Assert.Single(videoDtos);

            // Get video id
            int videoId = videoDtos.ElementAt(0).Id;

            // make videoId invalid
            videoId++;

            // Create request with invalid id
            var getVideoRequest = new GetVideoById(videoId);

            // Make sure that an exception is thrown when video retrieval is attempted
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await _fixture.SendAsync(getVideoRequest));
        }
Beispiel #5
0
        public async Task Should_ReturnTwoVideos_When_UserCreatesTwoVideos()
        {
            // Create a test user
            var userRequest = new CreateUserWithoutAuth("Alice");
            var user        = await _fixture.SendAsync(userRequest);

            const string title       = "My Fantastic Library";
            const string description = "A suitable description.";

            // User creates library
            var createLibraryRequest = new CreateLibrary(user.Id, title, description);
            await _fixture.SendAsync(createLibraryRequest);

            // Get libraries just created by user
            var getLibrariesRequest = new GetLibrariesForUser(user.Id);
            var libraries           = await _fixture.SendAsync(getLibrariesRequest);

            // Make sure there's only one library
            var libraryDtos = libraries.ToList();

            Assert.Single(libraryDtos);

            // Get id of the single library
            var libraryId = libraryDtos.ToList().ElementAt(0).Id;

            // Create two videos for library
            const string vidTitle       = "Video Title";
            const string videoUrl       = "https://www.youtube.com/watch?v=-O5kNPlUV7w";
            const string videoUrl2      = "https://www.youtube.com/watch?v=-O5kNPlUV7a";
            const string vidDescription = "Video description";

            var createVideosRequest1 = new CreateVideo(user.Id, libraryId, vidTitle, videoUrl, vidDescription);
            var createVideosRequest2 = new CreateVideo(user.Id, libraryId, vidTitle, videoUrl2, vidDescription);

            await _fixture.SendAsync(createVideosRequest1);

            await _fixture.SendAsync(createVideosRequest2);

            // Get videos for library
            var getVideosRequest = new GetVideosOfLibrary(libraryId);
            var videos           = await _fixture.SendAsync(getVideosRequest);

            // Make sure correct number of videos returned
            var videoDtos = videos.ToList();

            Assert.Equal(2, videoDtos.Count);

            // Make sure the videos have the same content
            foreach (var video in videoDtos)
            {
                Assert.Equal(vidTitle, video.Title);
                Assert.Equal(vidDescription, video.Description);
            }
        }
Beispiel #6
0
        public async Task Should_ReturnCorrectVideo_When_GivenValidId()
        {
            // Create a test user
            var userRequest = new CreateUserWithoutAuth("Alice");
            var user        = await _fixture.SendAsync(userRequest);

            const string title       = "My Fantastic Library";
            const string description = "A suitable description.";

            // User creates library
            var createLibraryRequest = new CreateLibrary(user.Id, title, description);
            await _fixture.SendAsync(createLibraryRequest);

            // Get libraries just created by user
            var getLibrariesRequest = new GetLibrariesForUser(user.Id);
            var libraries           = await _fixture.SendAsync(getLibrariesRequest);

            // Make sure there's only one library
            var libraryDtos = libraries.ToList();

            Assert.Single(libraryDtos);

            // Get id of the single library
            var libraryId = libraryDtos.ToList().ElementAt(0).Id;

            // Create two videos for library
            const string videoTitle       = "Video Title";
            const string videoUrl         = "https://www.youtube.com/watch?v=-O5kNPlUV7w";
            const string videoDescription = "Video Description";

            var createVideosRequest1 = new CreateVideo(user.Id, libraryId, videoTitle, videoUrl, videoDescription);

            await _fixture.SendAsync(createVideosRequest1);

            // Get videos for library
            var getVideosRequest = new GetVideosOfLibrary(libraryId);
            var videos           = await _fixture.SendAsync(getVideosRequest);

            // Make sure correct number of videos returned
            var videoDtos = videos.ToList();

            Assert.Single(videoDtos);

            // Get video id
            int videoId = videoDtos.ElementAt(0).Id;

            // Get the video using the id
            var getVideoRequest = new GetVideoById(videoId);
            var video           = await _fixture.SendAsync(getVideoRequest);

            // Make sure the video's properties match the properties given on creation
            Assert.Equal(videoTitle, video.Title);
            Assert.Equal(videoDescription, video.Description);
        }
Beispiel #7
0
        public async Task Should_ReturnNone_When_VideoHasNoAnnotations()
        {
            // Create a test user
            var userRequest = new CreateUserWithoutAuth("Alice");
            var user        = await _fixture.SendAsync(userRequest);

            const string title       = "My Fantastic Library";
            const string description = "A suitable description.";

            // User creates library
            var createLibraryRequest = new CreateLibrary(user.Id, title, description);
            await _fixture.SendAsync(createLibraryRequest);

            // Get libraries just created by user
            var getLibrariesRequest = new GetLibrariesForUser(user.Id);
            var libraries           = await _fixture.SendAsync(getLibrariesRequest);

            // Get id of the single library
            var libraryDtos = libraries.ToList();
            var libraryId   = libraryDtos.ElementAt(0).Id;

            // create video
            var vidTitle       = "Video title";
            var vidLink        = "Link goes here";
            var vidDescription = "Video description";

            var createVideoRequest = new CreateVideo(user.Id, libraryId, vidTitle, vidLink, vidDescription);
            await _fixture.SendAsync(createVideoRequest);

            // Get video
            var getVideosRequest = new GetVideosOfLibrary(libraryId);
            var videos           = await _fixture.SendAsync(getVideosRequest);

            var video = videos.ToList().ElementAt(0);

            // Get annotations, and ensure none exist yet, since none have been created
            var getAnnotationsRequest = new GetAnnotationsByVideoId(video.Id);
            var annotations           = await _fixture.SendAsync(getAnnotationsRequest);

            Assert.Empty(annotations);
        }
Beispiel #8
0
        public async Task Should_ReturnZero_When_UserDeletesReply()
        {
            // Create a test user
            var userRequest = new CreateUserWithoutAuth("Bebe");
            var user        = await _fixture.SendAsync(userRequest);

            const string title       = "My Cat Thumper";
            const string description = "Thumper is 12 years old";

            // User creates library
            var createLibraryRequest = new CreateLibrary(user.Id, title, description);
            await _fixture.SendAsync(createLibraryRequest);

            // Get libraries just created by user
            var getLibrariesRequest = new GetLibrariesForUser(user.Id);
            var libraries           = await _fixture.SendAsync(getLibrariesRequest);

            // Get id of the single library
            var libraryDtos = libraries.ToList();
            var libraryId   = libraryDtos.ElementAt(0).Id;

            // create video
            var vidTitle       = "Video title";
            var vidLink        = "Link goes here";
            var vidDescription = "Video description";

            var createVideoRequest = new CreateVideo(user.Id, libraryId, vidTitle, vidLink, vidDescription);
            await _fixture.SendAsync(createVideoRequest);

            // Get video
            var getVideosRequest = new GetVideosOfLibrary(libraryId);
            var videos           = await _fixture.SendAsync(getVideosRequest);

            var video = videos.ToList().ElementAt(0);

            // Create 1 annotation
            var comment1   = "This is a comment!";
            var timestamp1 = 2.05;

            var annotationRequest1 = new CreateAnnotation(user.Id, comment1, video.Id, timestamp1);

            await _fixture.SendAsync(annotationRequest1);

            // get annotations
            var getAnnotationsRequest = new GetAnnotationsByVideoId(video.Id);
            var results = await _fixture.SendAsync(getAnnotationsRequest);

            var annotation = results.ToList().ElementAt(0);

            // create reply
            var replyText1          = "Such a great annotation";
            var createReplyRequest1 = new CreateAnnotationReply(user.Id, annotation.Id, replyText1);
            await _fixture.SendAsync(createReplyRequest1);

            // Get reply
            var getReplyRequest = new GetAnnotationRepliesByVideoId(video.Id);
            var replyResults1   = await _fixture.SendAsync(getReplyRequest);

            var reply = replyResults1.Single();

            // delete reply
            var deleteReplyRequest = new DeleteAnnotationReply(user.Id, reply.Id);
            await _fixture.SendAsync(deleteReplyRequest);

            // get replies
            var getRepliesRequest = new GetAnnotationRepliesByVideoId(video.Id);
            var replyResults      = await _fixture.SendAsync(getRepliesRequest);

            var replies = replyResults.ToList();

            // Check that no replies are in database
            Assert.Empty(replies);
        }
Beispiel #9
0
        public async Task Should_DeleteAnnotation_When_UserDeletesAnnotation()
        {
            // Create a test user
            var userRequest = new CreateUserWithoutAuth("Alice");
            var user        = await _fixture.SendAsync(userRequest);

            const string title       = "My Fantastic Library";
            const string description = "A suitable description.";

            // User creates library
            var createLibraryRequest = new CreateLibrary(user.Id, title, description);
            await _fixture.SendAsync(createLibraryRequest);

            // Get libraries just created by user
            var getLibrariesRequest = new GetLibrariesForUser(user.Id);
            var libraries           = await _fixture.SendAsync(getLibrariesRequest);

            // Get id of the single library
            var libraryDtos = libraries.ToList();
            var libraryId   = libraryDtos.ElementAt(0).Id;

            // create video
            var vidTitle       = "Video title";
            var vidLink        = "Link goes here";
            var vidDescription = "Video description";

            var createVideoRequest = new CreateVideo(user.Id, libraryId, vidTitle, vidLink, vidDescription);
            await _fixture.SendAsync(createVideoRequest);

            // Get video
            var getVideosRequest = new GetVideosOfLibrary(libraryId);
            var videos           = await _fixture.SendAsync(getVideosRequest);

            var video = videos.ToList().ElementAt(0);

            // Create two annotations
            var comment1   = "This is a comment!";
            var comment2   = "This is another comment!";
            var timestamp1 = 1.25;
            var timestamp2 = 18.45;

            var annotationRequest1 = new CreateAnnotation(user.Id, comment1, video.Id, timestamp1);
            var annotationRequest2 = new CreateAnnotation(user.Id, comment2, video.Id, timestamp2);

            await _fixture.SendAsync(annotationRequest1);

            await _fixture.SendAsync(annotationRequest2);

            // get annotations
            var getAnnotationsRequest = new GetAnnotationsByVideoId(video.Id);
            var results = await _fixture.SendAsync(getAnnotationsRequest);

            var annotations = results.ToList();

            // Check that two annotations were created
            Assert.Equal(2, annotations.Count);

            // Delete the first annotation in the list
            var annotation1 = annotations.ElementAt(0);

            var deleteAnnotationRequest = new DeleteAnnotation(user.Id, annotation1.Id);
            await _fixture.SendAsync(deleteAnnotationRequest);

            // Get annotations after deleting one of them and make sure there's only one now
            var getNewAnnotationsRequest = new GetAnnotationsByVideoId(video.Id);
            var afterDeleteResults       = await _fixture.SendAsync(getNewAnnotationsRequest);

            var afterDeleteAnnotations = afterDeleteResults.ToList();

            // Check that there are two annotations
            Assert.Equal(1, afterDeleteAnnotations.Count);
            Assert.Equal(comment1, afterDeleteAnnotations.ElementAt(0).Comment);
        }
Beispiel #10
0
        public async Task Should_ReturnRightPhrase_When_UserEditsReply()
        {
            // Create a test user
            var userRequest = new CreateUserWithoutAuth("Wendy");
            var user        = await _fixture.SendAsync(userRequest);

            const string title       = "The New Cold War";
            const string description = "Dork alert.";

            // User creates library
            var createLibraryRequest = new CreateLibrary(user.Id, title, description);
            await _fixture.SendAsync(createLibraryRequest);

            // Get libraries just created by user
            var getLibrariesRequest = new GetLibrariesForUser(user.Id);
            var libraries           = await _fixture.SendAsync(getLibrariesRequest);

            // Get id of the single library
            var libraryDtos = libraries.ToList();
            var libraryId   = libraryDtos.ElementAt(0).Id;

            // create video
            var vidTitle       = "Video title";
            var vidLink        = "Link goes here";
            var vidDescription = "Video description";

            var createVideoRequest = new CreateVideo(user.Id, libraryId, vidTitle, vidLink, vidDescription);
            await _fixture.SendAsync(createVideoRequest);

            // Get video
            var getVideosRequest = new GetVideosOfLibrary(libraryId);
            var videos           = await _fixture.SendAsync(getVideosRequest);

            var video = videos.ToList().ElementAt(0);

            // Create 1 annotation
            var comment1   = "God you're so stupid!";
            var timestamp1 = 0.46;

            var annotationRequest1 = new CreateAnnotation(user.Id, comment1, video.Id, timestamp1);

            await _fixture.SendAsync(annotationRequest1);

            // get annotations
            var getAnnotationsRequest = new GetAnnotationsByVideoId(video.Id);
            var results = await _fixture.SendAsync(getAnnotationsRequest);

            var annotation = results.ToList().ElementAt(0);

            // create reply
            var replyText1    = "I have three thousand dollars, cash";
            var new_replyText = "I have $38 and a gold bracelet";

            var createReplyRequest1 = new CreateAnnotationReply(user.Id, annotation.Id, replyText1);

            await _fixture.SendAsync(createReplyRequest1);

            // get reply
            var getReplyRequest = new GetAnnotationRepliesByVideoId(video.Id);
            var replyResults1   = await _fixture.SendAsync(getReplyRequest);

            var reply = replyResults1.Single();

            // edit reply
            var editReplyRequest = new EditAnnotationReply(user.Id, reply.Id, new_replyText);
            await _fixture.SendAsync(editReplyRequest);

            // get replies
            var getRepliesRequest = new GetAnnotationRepliesByVideoId(video.Id);
            var replyResults      = await _fixture.SendAsync(getRepliesRequest);

            var replies = replyResults.ToList();
            var reply1  = replies.ElementAt(0);

            // Check that reply got created
            Assert.Single(replies);

            // Check that reply returns right thing
            Assert.Equal(new_replyText, reply1.Text);
        }
 public IVideoModel Any(CreateVideo request)
 {
     return(workflow.Create(request));
 }
Beispiel #12
0
        public async Task Should_ReturnTwoReplies_When_UserCreatesTwoRepliesOnSameAnnotation()
        {
            // Create a test user
            var userRequest = new CreateUserWithoutAuth("Alice");
            var user        = await _fixture.SendAsync(userRequest);

            const string title       = "My Fantastic Library";
            const string description = "A suitable description.";

            // User creates library
            var createLibraryRequest = new CreateLibrary(user.Id, title, description);
            await _fixture.SendAsync(createLibraryRequest);

            // Get libraries just created by user
            var getLibrariesRequest = new GetLibrariesForUser(user.Id);
            var libraries           = await _fixture.SendAsync(getLibrariesRequest);

            // Get id of the single library
            var libraryDtos = libraries.ToList();
            var libraryId   = libraryDtos.ElementAt(0).Id;

            // create video
            var vidTitle       = "Video title";
            var vidLink        = "Link goes here";
            var vidDescription = "Video description";

            var createVideoRequest = new CreateVideo(user.Id, libraryId, vidTitle, vidLink, vidDescription);
            await _fixture.SendAsync(createVideoRequest);

            // Get video
            var getVideosRequest = new GetVideosOfLibrary(libraryId);
            var videos           = await _fixture.SendAsync(getVideosRequest);

            var video = videos.ToList().ElementAt(0);

            // Create two annotations
            var comment1   = "This is a comment!";
            var timestamp1 = 1.25;

            var annotationRequest1 = new CreateAnnotation(user.Id, comment1, video.Id, timestamp1);

            await _fixture.SendAsync(annotationRequest1);

            // get annotations
            var getAnnotationsRequest = new GetAnnotationsByVideoId(video.Id);
            var results = await _fixture.SendAsync(getAnnotationsRequest);

            var annotation = results.ToList().ElementAt(0);

            // create replies
            var replyText1 = "This is a reply";
            var replyText2 = "This is another reply";

            var createReplyRequest1 = new CreateAnnotationReply(user.Id, annotation.Id, replyText1);
            var createReplyRequest2 = new CreateAnnotationReply(user.Id, annotation.Id, replyText2);

            await _fixture.SendAsync(createReplyRequest1);

            await _fixture.SendAsync(createReplyRequest2);

            // get replies
            var getRepliesRequest = new GetAnnotationRepliesByAnnotationId(annotation.Id);
            var replyResults      = await _fixture.SendAsync(getRepliesRequest);

            var replies = replyResults.ToList();

            var reply1 = replies.ElementAt(0);
            var reply2 = replies.ElementAt(1);

            // Check that both replies got created
            Assert.Equal(2, replies.Count);

            // Check that the properties of the replies are correct
            Assert.Equal(replyText1, reply1.Text);
            Assert.Equal(replyText2, reply2.Text);
        }
Beispiel #13
0
        public async Task Should_ReturnCorrectData_When_UserEditsAnnotation()
        {
            // Create a test user
            var userRequest = new CreateUserWithoutAuth("Alice");
            var user        = await _fixture.SendAsync(userRequest);

            const string title       = "My Fantastic Library";
            const string description = "A suitable description.";

            // User creates library
            var createLibraryRequest = new CreateLibrary(user.Id, title, description);
            await _fixture.SendAsync(createLibraryRequest);

            // Get libraries just created by user
            var getLibrariesRequest = new GetLibrariesForUser(user.Id);
            var libraries           = await _fixture.SendAsync(getLibrariesRequest);

            // Get id of the single library
            var libraryDtos = libraries.ToList();
            var libraryId   = libraryDtos.ElementAt(0).Id;

            // create video
            var vidTitle       = "Video title";
            var vidLink        = "Link goes here";
            var vidDescription = "Video description";

            var createVideoRequest = new CreateVideo(user.Id, libraryId, vidTitle, vidLink, vidDescription);
            await _fixture.SendAsync(createVideoRequest);

            // Get video
            var getVideosRequest = new GetVideosOfLibrary(libraryId);
            var videos           = await _fixture.SendAsync(getVideosRequest);

            var video = videos.ToList().ElementAt(0);

            // Create two annotations
            var comment1   = "This is a comment!";
            var comment2   = "This is another comment!";
            var timestamp1 = 1.25;
            var timestamp2 = 18.45;

            var annotationRequest1 = new CreateAnnotation(user.Id, comment1, video.Id, timestamp1);
            var annotationRequest2 = new CreateAnnotation(user.Id, comment2, video.Id, timestamp2);

            await _fixture.SendAsync(annotationRequest1);

            await _fixture.SendAsync(annotationRequest2);

            // get annotations
            var getAnnotationsRequest = new GetAnnotationsByVideoId(video.Id);
            var results = await _fixture.SendAsync(getAnnotationsRequest);

            var annotations = results.ToList();

            // Edit annotations
            var newComment1 = "New comment1!";
            var newComment2 = "New Comment2!";

            var editAnnotationRequest1 = new EditAnnotation(user.Id, newComment1, annotations.ElementAt(0).Id);
            var editAnnotationRequest2 = new EditAnnotation(user.Id, newComment2, annotations.ElementAt(1).Id);
            await _fixture.SendAsync(editAnnotationRequest1);

            await _fixture.SendAsync(editAnnotationRequest2);

            // Get edited annotations
            var getEditedAnnotationsRequest = new GetAnnotationsByVideoId(video.Id);
            var editedResults = await _fixture.SendAsync(getEditedAnnotationsRequest);

            var editedAnnotations = editedResults.ToList();

            // Check that there are two annotations
            Assert.Equal(2, editedAnnotations.Count);

            // Check that the comments of each annotation match the edited comments
            var annotation1 = editedAnnotations.ElementAt(0);
            var annotation2 = editedAnnotations.ElementAt(1);

            Assert.Equal(newComment1, annotation1.Comment);
            Assert.Equal(newComment2, annotation2.Comment);
        }
Beispiel #14
0
        public static async Task Start()
        {
            if (!BatchProcessing.busy && Program.busy)
            {
                return;
            }
            canceled = false;
            Program.mainForm.SetWorking(true);
            if (!Utils.InputIsValid(current.inPath, current.outPath, current.outFps, current.interpFactor, current.outMode))
            {
                return;                                                                                                                  // General input checks
            }
            if (!Utils.CheckAiAvailable(current.ai))
            {
                return;                                                 // Check if selected AI pkg is installed
            }
            if (!ResumeUtils.resumeNextRun && !Utils.CheckDeleteOldTempFolder())
            {
                return;                                                                       // Try to delete temp folder if an old one exists
            }
            if (!Utils.CheckPathValid(current.inPath))
            {
                return;                                                  // Check if input path/file is valid
            }
            if (!(await Utils.CheckEncoderValid()))
            {
                return;                                               // Check NVENC compat
            }
            Utils.PathAsciiCheck(current.outPath, "output path");
            currentInputFrameCount = await Utils.GetInputFrameCountAsync(current.inPath);

            current.stepByStep = false;
            Program.mainForm.SetStatus("Starting...");

            if (!ResumeUtils.resumeNextRun)
            {
                await GetFrames();

                if (canceled)
                {
                    return;
                }
                sw.Restart();
                await PostProcessFrames(false);
            }

            if (canceled)
            {
                return;
            }
            await ResumeUtils.PrepareResumedRun();

            //Task.Run(() => Utils.DeleteInterpolatedInputFrames());
            await RunAi(current.interpFolder, current.ai);

            if (canceled)
            {
                return;
            }
            Program.mainForm.SetProgress(100);
            if (!currentlyUsingAutoEnc)
            {
                await CreateVideo.Export(current.interpFolder, current.outFilename, current.outMode, false);
            }
            await IOUtils.ReverseRenaming(current.framesFolder, AiProcess.filenameMap);   // Get timestamps back

            AiProcess.filenameMap.Clear();
            await Cleanup();

            Program.mainForm.SetWorking(false);
            Logger.Log("Total processing time: " + FormatUtils.Time(sw.Elapsed));
            sw.Stop();
            Program.mainForm.SetStatus("Done interpolating!");
        }