Ejemplo n.º 1
0
        public void GivenAStoredImage_WhenTheImageUrlIsConstructed_ThenTheImageIsReturned()
        {
            var logger = new Mock<ILogger>();
            string connectionString = ConfigurationManager.ConnectionStrings["mblog"].ConnectionString;
            string key = "filename";
            IUserService userService = new UserService(new UserRepository(connectionString),
                                                       new UsernameBlacklistRepository(connectionString), 
                                                       logger.Object);
            User user = userService.CreateUser("name", "email", "password");

            IMediaRepository repository = new MediaRepository(connectionString);
            IMediaService mediaService = new MediaService(repository);
            var controller = new MediaController(mediaService, logger.Object);

            var stream = new MemoryStream(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0});

            mediaService.WriteMedia(key, user.Id, "image/png", stream, 10);

            ActionResult result = controller.Show(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, key);
            Assert.That(result, Is.Not.Null);
        }
Ejemplo n.º 2
0
 public void Setup()
 {
     _mediaRepository = new Mock<IMediaRepository>();
     mediaService = new MediaService(_mediaRepository.Object);
 }