public async Task TestGetVideoWithPeople_InvalidParameters_ReturnsBadResult() { var context = new TestContext(); context.Users.Add(new User { UserId = 1, Username = "******" }); var video = GetDemoVideoInstance(1); video.Participants.Add(new Participant { Name = "tester" }); context.Videos.Add(video); 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; var result = await controller.GetVideosWithPeople(null, "nosuchuser"); Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult)); }
public async Task TestGetVideoWithPeople_ReturnsVideos() { var context = new TestContext(); context.Users.Add(new User { UserId = 1, Username = "******" }); var video = GetDemoVideoInstance(1); video.Participants.Add(new Participant { Name = "tester" }); context.Videos.Add(video); 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; var result = await controller.GetVideosWithPeople(new List <string> { "tester" }, "testuser") as OkNegotiatedContentResult <IList <VideoModel> >; Assert.IsNotNull(result); Assert.IsNotNull(result.Content); Assert.AreEqual(result.Content.Count, 1); }