Example #1
0
 public void Should_Not_Accept_Invalid_Size(int invalidSizes)
 {
     Assert.Throws <ArgumentException>(() =>
                                       VideoBuilder.New().VideoWithSize(invalidSizes).Build()
                                       )
     .AssertThrowsWithMessage("Size file not valid!");
 }
Example #2
0
 public void Should_Not_Accept_Invalid_Description(string invalidDescriptions)
 {
     Assert.Throws <ArgumentException>(() =>
                                       VideoBuilder.New().VideoWithDescription(invalidDescriptions).Build()
                                       )
     .AssertThrowsWithMessage("Description is required!");
 }
Example #3
0
 public void Should_Not_Accept_Invalid_File(string invalidFiles)
 {
     Assert.Throws <ArgumentException>(() =>
                                       VideoBuilder.New().VideoWithFile(invalidFiles).Build()
                                       )
     .AssertThrowsWithMessage("File is required!");
 }
            public async Task InitializeAsync()
            {
                Video = VideoBuilder.CreateVideo("Nice Test Video").Build();

                var httpContent = new ObjectContent <Video>(Video, new JsonMediaTypeFormatter(), "application/json");

                Response = await _factory.HttpClient
                           .PostAsync("/api/videos", httpContent);
            }
Example #5
0
        public async Task <ActionResult <Video> > PostVideo(VideoBuilder URL)
        {
            string videoID  = YoutubeHelper.GetVideoLink(URL.URL);
            Video  newVideo = YoutubeHelper.getVideoInfo(videoID);

            _context.Video.Add(newVideo);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetVideo", new { id = newVideo.VideoId }, newVideo));
        }
Example #6
0
        public async Task ReturnsOkWithVideoWhenMatchingVideoId()
        {
            var video = VideoBuilder.CreateVideo("Some Video").Build();

            _session
            .ExecuteAsync(Arg.Is <GetVideoByIdQuery>(q => q.VideoId == video.VideoId))
            .Returns(video);

            var result = await _controller.Get(video.VideoId);

            result.Should().BeOfType <OkObjectResult>().Which.Value
            .Should().BeEquivalentTo(video);
        }
            public async Task InitializeAsync()
            {
                Video = VideoBuilder.CreateVideo("Cool Removable Video").Build();

                using (var session = _factory.SessionFactory.CreateCommandSession())
                {
                    await session.ExecuteAsync(new InsertVideoCommand(Video));

                    session.Commit();
                }

                Response = await _factory.HttpClient
                           .DeleteAsync($"/api/videos/{Video.VideoId}");
            }
            public async Task InitializeAsync()
            {
                _originalVideo = VideoBuilder.CreateVideo("Cool OG Video").Build();

                using (var session = _factory.SessionFactory.CreateCommandSession())
                {
                    session.Execute(new InsertVideoCommand(_originalVideo));
                    session.Commit();
                }

                UpdatedVideo = VideoBuilder.CreateVideo("Cool New Video")
                               .WithId(_originalVideo.VideoId)
                               .Build();

                var httpContent = new ObjectContent <Video>(UpdatedVideo, new JsonMediaTypeFormatter(), "application/json");

                Response = await _factory.HttpClient
                           .PutAsync($"/api/videos/{_originalVideo.VideoId}", httpContent);
            }
Example #9
0
        public async Task ReturnsNoContentWhenUpdateSuccessful()
        {
            var video = VideoBuilder.CreateVideo("Some Video").Build();

            _session
            .ExecuteAsync(Arg.Is <UpdateVideoCommand>(c =>
                                                      c.VideoId == video.VideoId &&
                                                      c.Details == video))
            .Returns(1);

            var result = await _controller.Put(video.VideoId, video);

            Received.InOrder(() =>
            {
                _session.Received(1).ExecuteAsync(Arg.Any <UpdateVideoCommand>());
                _session.Received(1).Commit();
                _session.Received(1).Dispose();
            });
            result.Should().BeOfType <NoContentResult>();
        }
Example #10
0
        public async Task ReturnsCreatedWhenModelStateValid()
        {
            var video = VideoBuilder.CreateVideo("Some Video").Build();

            var result = await _controller.Post(video);

            Received.InOrder(() =>
            {
                _session.Received(1).ExecuteAsync(Arg.Is <InsertVideoCommand>(c => c.Video == video));
                _session.Received(1).Commit();
                _session.Received(1).Dispose();
            });
            result.Should().BeOfType <CreatedAtActionResult>().Which
            .Should().BeEquivalentTo(new
            {
                ActionName  = nameof(VideosController.Get),
                RouteValues = new RouteValueDictionary {
                    { "videoId", video.VideoId }
                },
                Value = video
            });
        }
Example #11
0
        public async Task ReturnsOkWithEventsWhenSomeEvents()
        {
            var one   = VideoBuilder.CreateVideo("Cool Video").Build();
            var two   = VideoBuilder.CreateVideo("Cooler Video").Build();
            var three = VideoBuilder.CreateVideo("Coolest Video").Build();

            _session
            .ExecuteAsync(Arg.Any <GetAllVideosQuery>())
            .Returns(new[]
            {
                one,
                two,
                three
            });

            var result = await _controller.Get();

            result.Should().BeOfType <OkObjectResult>().Which.Value
            .Should().BeEquivalentTo(new [] {
                one,
                two,
                three
            });
        }