Пример #1
0
        public async Task TestGetVideoByTitle_InvalidParameters_ReturnVideo()
        {
            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);
            context.Videos.Add(GetDemoVideoInstance(1));
            var result = await controller.GetVideoByTitle(null, null);

            Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult));
        }
Пример #2
0
        public async Task TestGetVideoByTitle_ReturnVideo()
        {
            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);
            context.Videos.Add(GetDemoVideoInstance(1));
            var result = await controller.GetVideoByTitle("test", "testuser") as OkNegotiatedContentResult <VideoModel>;

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Content);
            Assert.AreEqual(result.Content.Title, "test");
        }