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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }