Ejemplo n.º 1
0
        public void When_AddVideo_is_called_with_a_new_Video_then_UploadVideo_on_the_VideoAdapter_is_called_with_that_Video_and_the_stored_VideoAdapterSettings()
        {
            var          photo    = new MemoryStream();
            const string fileName = "photo.jpg";
            const string photoId  = "http://www.photos.com/myphoto";
            var          entity   = AdapterSettingsCreator.CreateSingle();

            BandRepository
            .Expect(repository =>
                    repository.GetAdapterSettings(Arg <string> .Is.Anything))
            .Return(entity)
            .Repeat.Once();
            BandRepository.Replay();

            VideoAdapter
            .Expect(adapter =>
                    adapter.UploadItem(photo, entity.SetName, fileName, entity.OAuthAccessToken))
            .Return(photoId)
            .Repeat.Once();
            VideoAdapter.Replay();

            var result = Process.AddVideo(photo, fileName);

            Assert.AreEqual(photoId, result);

            VideoAdapter.VerifyAllExpectations();
        }
Ejemplo n.º 2
0
        public void When_AddVideo_is_called_and_no_OAuthAccessToken_has_been_stored_then_an_InvalidOperationException_is_thrown_and_UploadVideo_on_the_VideoAdapter_is_never_called()
        {
            var          photo    = new MemoryStream();
            const string fileName = "photo.jpg";
            var          entity   = AdapterSettingsCreator.CreateSingle();

            entity.OAuthAccessToken = null;

            BandRepository
            .Expect(repository =>
                    repository.GetAdapterSettings(Arg <string> .Is.Anything))
            .Return(entity)
            .Repeat.Once();
            BandRepository.Replay();

            VideoAdapter
            .Expect(adapter =>
                    adapter.UploadItem(null, null, null, null))
            .IgnoreArguments()
            .Return("")
            .Repeat.Never();
            VideoAdapter.Replay();

            Process.AddVideo(photo, fileName);

            VideoAdapter.VerifyAllExpectations();
        }
Ejemplo n.º 3
0
        public void When_GetVideo_is_called_with_a_new_Video_and_an_empty_string_for_setName_then_UploadVideo_on_the_VideoAdapter_is_called_with_that_Video_and_the_stored_VideoAdapterSettings()
        {
            var tracks = VideoCreator.CreateCollection();
            var entity = AdapterSettingsCreator.CreateSingle();

            entity.SetName = string.Empty;

            BandRepository
            .Expect(repository =>
                    repository.GetAdapterSettings(Arg <string> .Is.Anything))
            .Return(entity)
            .Repeat.Once();
            BandRepository.Replay();

            VideoAdapter
            .Expect(adapter =>
                    adapter.GetItems(entity.SetName, entity.OAuthAccessToken))
            .Return(tracks)
            .Repeat.Once();
            VideoAdapter.Replay();

            var result = Process.GetVideos();

            Assert.AreEqual(tracks.Count(), result.Count());
            Assert.AreEqual(tracks.First().ResourceUri, result.First().ResourceUri);

            VideoAdapter.VerifyAllExpectations();
        }
Ejemplo n.º 4
0
 public VideosController(
     VideoAdapter videoAdapter,
     IVideoService videoService)
 {
     _svc     = videoService ?? throw new ArgumentNullException(nameof(videoService));
     _adapter = videoAdapter ?? throw new ArgumentNullException(nameof(videoAdapter));
 }
Ejemplo n.º 5
0
        public void When_GetVideo_is_called_and_no_OAuthAccessToken_has_been_stored_then_an_InvalidOperationException_is_thrown_and_GetVideo_on_the_VideoAdapter_is_never_called()
        {
            var photoAdapterSettings = AdapterSettingsCreator.CreateSingle();

            photoAdapterSettings.OAuthAccessToken = null;

            BandRepository
            .Expect(repository =>
                    repository.GetAdapterSettings(Arg <string> .Is.Anything))
            .Return(photoAdapterSettings)
            .Repeat.Once();
            BandRepository.Replay();

            VideoAdapter
            .Expect(adapter =>
                    adapter.GetItems(null, null))
            .IgnoreArguments()
            .Return(new List <Video>())
            .Repeat.Never();
            VideoAdapter.Replay();

            Process.GetVideos(0, 10);

            VideoAdapter.VerifyAllExpectations();
        }
 public VideoCategoriesController(
     IVideoService videoService,
     VideoAdapter videoAdapter,
     VideoCategoryAdapter categoryAdapter)
 {
     _svc             = videoService ?? throw new ArgumentNullException(nameof(videoService));
     _videoAdapter    = videoAdapter ?? throw new ArgumentNullException(nameof(videoAdapter));
     _categoryAdapter = categoryAdapter ?? throw new ArgumentNullException(nameof(categoryAdapter));
 }
Ejemplo n.º 7
0
 public VideoPanel()
 {
     InitializeComponent();
     panelMain.MouseWheel += PanelMain_MouseWheel;
     _cameraAdapter = new VideoAdapter();
     _frameBuffer = new List<Bitmap>();
     panelMain.Disposed += PanelMain_Disposed;
     _cameraAdapter.SnapProcess += CameraAdap_SnapProcess;
 }
Ejemplo n.º 8
0
        public Video GetVideo(int id)
        {
            var adapterSettings = GetAdapterSettings();

            if (adapterSettings.OAuthAccessToken == null)
            {
                throw new AuthorizationException();
            }

            return(VideoAdapter.GetItem(id, adapterSettings.OAuthAccessToken));
        }
Ejemplo n.º 9
0
        public IEnumerable <Video> GetVideos(int page, int pageSize)
        {
            var adapterSettings = GetAdapterSettings();

            if (adapterSettings.OAuthAccessToken == null)
            {
                throw new AuthorizationException();
            }

            return(VideoAdapter.GetItems(adapterSettings.SetName, adapterSettings.OAuthAccessToken, page, pageSize));
        }
Ejemplo n.º 10
0
        public string AddVideo(Stream video, string fileName)
        {
            if (video == null)
            {
                throw new ArgumentNullException("video");
            }
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }

            var adapterSettings = BandRepository.GetAdapterSettings(AdapterName);

            if (adapterSettings.OAuthAccessToken == null)
            {
                throw new AuthorizationException();
            }

            return(VideoAdapter.UploadItem(video, adapterSettings.SetName, fileName, adapterSettings.OAuthAccessToken));
        }
Ejemplo n.º 11
0
        public void When_GetVideo_is_called_then_GetVideoAdapterSettings_on_the_BandRepository_is_called()
        {
            var tracks = VideoCreator.CreateCollection();
            var entity = AdapterSettingsCreator.CreateSingle();

            BandRepository
            .Expect(repository =>
                    repository.GetAdapterSettings(Arg <string> .Is.Anything))
            .Return(entity)
            .Repeat.Once();
            BandRepository.Replay();

            VideoAdapter
            .Expect(adapter =>
                    adapter.GetItems(entity.SetName, entity.OAuthAccessToken))
            .Return(tracks)
            .Repeat.Once();
            VideoAdapter.Replay();

            Process.GetVideos();

            BandRepository.VerifyAllExpectations();
        }
Ejemplo n.º 12
0
        protected virtual void ReleaseVideoAdapter(VideoAdapter videoAdapter)
        {
            if (VideoAdapter.Controller == null)
                VideoAdapter.Controller = null;

            VideoAdapter.CurrentItem = null;
            VideoAdapter.Dispose();
        }
Ejemplo n.º 13
0
 public virtual VideoAdapter GetVideoAdapter(VideoAdapter adapter)
 {
     VideoAdapter = new MediaElementVideoAdapter();
     return VideoAdapter;
 }