Beispiel #1
0
        public void GetUserByVideoId_ShouldGetUser()
        {
            var videoRepositoryMock       = new Mock <IRepository <Video> >();
            var unitOfWorkMock            = new Mock <IUnitOfWork>();
            var commentRepositoryMock     = new Mock <IRepository <Comment> >();
            var userRepositoryMock        = new Mock <IRepository <VidconfileUser> >();
            var passwordHasherMock        = new Mock <IPasswordHasher>();
            var subscribeToSubscriberMock = new Mock <IRepository <SubscribeToSubscribers> >();

            Guid id = Guid.NewGuid();

            var video = new Video();

            video.Id = id;

            VidconfileUser user = new VidconfileUser();

            video.Uploader = user;

            var videos = new List <Video>();

            videos.Add(video);

            videoRepositoryMock.Setup(x => x.All(s => s.Uploader))
            .Returns(videos.AsQueryable());

            VidconfileUserServices userService =
                new VidconfileUserServices(userRepositoryMock.Object, unitOfWorkMock.Object, passwordHasherMock.Object,
                                           videoRepositoryMock.Object, subscribeToSubscriberMock.Object);

            var res = userService.GetUserByVideoId(id);

            Assert.Same(user, res);
            videoRepositoryMock.Verify(x => x.All(s => s.Uploader), Times.Once);
        }
Beispiel #2
0
        public void GetUserByVideoId_NonExistingVideo_ShoudReturnNull()
        {
            var videoRepositoryMock       = new Mock <IRepository <Video> >();
            var unitOfWorkMock            = new Mock <IUnitOfWork>();
            var commentRepositoryMock     = new Mock <IRepository <Comment> >();
            var userRepositoryMock        = new Mock <IRepository <VidconfileUser> >();
            var passwordHasherMock        = new Mock <IPasswordHasher>();
            var subscribeToSubscriberMock = new Mock <IRepository <SubscribeToSubscribers> >();



            VidconfileUserServices userService =
                new VidconfileUserServices(userRepositoryMock.Object, unitOfWorkMock.Object, passwordHasherMock.Object,
                                           videoRepositoryMock.Object, subscribeToSubscriberMock.Object);

            Guid id = Guid.NewGuid();

            var res = userService.GetUserByVideoId(id);

            Assert.Null(res);
        }