public ActionResult Add() { var fileStoreSvc = new FileStoreService(); string filePath = fileStoreSvc.SaveNew(Request.Files[0].InputStream); string fileName = Path.GetFileName(filePath); var photo = new Photo() { CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, Description = "My new photo", Filename = fileName, }; var albumsvc = new AlbumService(); var album = albumsvc.GetById(2); album.Photos.Add(photo); albumsvc.Save(); return View(); }
public void GetById_with_valid_id_returns_not_null() { var albumSvc = new AlbumService(_albumRepository); Assert.IsNotNull(albumSvc.GetById(ValidId)); }
public void GetPreviousPhoto_returns_not_null() { var mockAlbumRepo = new Mock<IAlbumRepository>(); mockAlbumRepo.Setup(p => p.GetById(It.IsAny<int>())).Returns(_albums.Where(p => p.ID == 50).Single()); var albumSvc = new AlbumService(mockAlbumRepo.Object); var album = albumSvc.GetById(50); var photo = album.Photos.ElementAt(25); var prevPhoto = albumSvc.GetPreviousPhoto(photo); Assert.IsNotNull(prevPhoto); Assert.AreEqual(24, prevPhoto.ID); }
public void GetById_with_exception_thrown_by_repo_returns_null() { var albumSvc = new AlbumService(_albumRepository); Assert.IsNull(albumSvc.GetById(ExceptionId)); }