Exemple #1
0
        public void getAllVideosTest()
        {
            VideoMapperMock mapper = new VideoMapperMock();

            mapper.returnVideos = new List <Video>();
            VideoService service = new VideoService(new TokenServiceMock(), mapper, new AccountMapperMock());

            service.getAllVideos("test");
            Assert.Equal(mapper.callCount, 1);
        }
Exemple #2
0
        public void getAllVideosByChannelTest()
        {
            VideoMapperMock mapper = new VideoMapperMock();

            mapper.returnVideos = new List <Video>();
            VideoService service = new VideoService(new TokenServiceMock(), mapper, new AccountMapperMock());
            Exception    ex      = Assert.Throws <AppObjectNotFoundException>(() => service.getAllVideosByChannel("test", 2));

            mapper.returnChannel = new Channel {
                ID    = 1,
                title = "test",
            };
            ChannelVideosDTO vidsInChannel = service.getAllVideosByChannel("test", 2);

            Assert.Equal(vidsInChannel.channelID, 1);
            Assert.Equal(vidsInChannel.title, "test");
        }
Exemple #3
0
        public void deleteVideoTest()
        {
            VideoMapperMock mapper = new VideoMapperMock();

            mapper.returnVideos = new List <Video>();
            VideoService service = new VideoService(new TokenServiceMock(), mapper, new AccountMapperMock());
            Exception    ex      = Assert.Throws <AppObjectNotFoundException>(() => service.deleteVideo("test", 2));

            mapper.returnVideo = new Video {
                channelId = 1,
                creator   = 5
            };
            Exception ex2 = Assert.Throws <AppValidationException>(() => service.deleteVideo("test", 2));

            mapper.returnVideo = new Video {
                channelId = 1,
                creator   = 1
            };
            service.deleteVideo("test", 2);
            Assert.Equal(mapper.deleteVideoCallCount, 1);
        }
Exemple #4
0
        public void addChannelVideoTest()
        {
            VideoMapperMock mapper = new VideoMapperMock();

            mapper.returnVideos = new List <Video>();
            VideoService service = new VideoService(new TokenServiceMock(), mapper, new AccountMapperMock());
            VideoDTO     vid     = new VideoDTO {
                title = "test"
            };
            Exception ex = Assert.Throws <InvalidParametersException>(() => service.addChannelVideo("test", 2, vid));

            vid.source = "testing";
            Exception ex2 = Assert.Throws <AppObjectNotFoundException>(() => service.addChannelVideo("test", 2, vid));

            mapper.returnChannel = new Channel {
                ID    = 1,
                title = "test",
            };
            service.addChannelVideo("test", 2, vid);
            Assert.Equal(mapper.addVideoCallCount, 1);
        }