Exemple #1
0
        public void TestGetVideoPorIdEntregaUnArchivo()
        {
            string ruta       = buscarpelicula() + "1280.mp4";
            var    fileStream = File.Open(ruta, System.IO.FileMode.Open);

            try
            {
                var mockEntity = Mock.Of <MediaEntity>(obj =>
                                                       obj.Ruta == "Streaming\\StreamingMovies\\1280.mp4"
                                                       );
                var Repo        = new Mock <IStreamRepository>();
                var controlador = new VideoController(Repo.Object);
                Repo.Setup(obj => obj.GetFileById(It.IsAny <string>(), controlador))
                .Returns(controlador.File(fileStream, "application/octet-stream"));
                Repo.Setup(obj => obj.getMediaById(It.IsAny <string>())).Returns(mockEntity);

                var result = controlador.getFileById(It.IsAny <string>());
                result.ShouldBeOfType <FileStreamResult>();
                (result as FileStreamResult).FileStream.ShouldBe(fileStream);
                //Etc
            }
            catch (Exception e)
            {
                Assert.True(false);
            }
            finally
            {
                fileStream.Close();
            }
        }