Exemplo n.º 1
0
        public async Task TestGetVideoByLink_NoSuchVideo_ReturnsBadResult()
        {
            var context = new TestContext();

            context.Users.Add(new User
            {
                UserId   = 1,
                Username = "******"
            });

            var controller = new VideosController(context);
            var location   = "http://location/";
            var mockUrl    = new Mock <UrlHelper>();

            mockUrl.Setup(x => x.Link(It.IsAny <string>(), It.IsAny <object>())).Returns(location);
            controller.Url = mockUrl.Object;
            context.Videos.Add(GetDemoVideoInstance(1));
            var result = await controller.GetVideoByLink("nosuchlink", "testuser");

            Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult));
        }
Exemplo n.º 2
0
        public async Task TestGetVideoByLink_ReturnsVideo()
        {
            var context = new TestContext();

            context.Users.Add(new User
            {
                UserId   = 1,
                Username = "******"
            });

            var controller = new VideosController(context);
            var location   = "http://location/";
            var mockUrl    = new Mock <UrlHelper>();

            mockUrl.Setup(x => x.Link(It.IsAny <string>(), It.IsAny <object>())).Returns(location);
            controller.Url = mockUrl.Object;
            context.Videos.Add(GetDemoVideoInstance(1));
            var result = await controller.GetVideoByLink("test.com/check", "testuser") as OkNegotiatedContentResult <VideoModel>;

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Content);
            Assert.AreEqual(result.Content.VideoId, 1);
        }