public async Task GetAsync_ReturnsEmptyList_WhenGivenNonsenseUserId() { var mockRepo = new Mock <IPhotoAlbumRepository>(); var userId = -1; mockRepo .Setup(repo => repo.GetPhotoAlbumsAsync(userId)) .ReturnsAsync(new List <PhotoAlbum>()); var controller = new PhotoAlbumsController(mockRepo.Object); var result = await controller.GetAsync(userId); Assert.AreEqual(0, result.Count()); }
public async Task GetAsync_ReturnsAlbumsWithPhotos() { var mockRepo = new Mock <IPhotoAlbumRepository>(); var userId = 1; mockRepo .Setup(repo => repo.GetPhotoAlbumsAsync(userId)) .ReturnsAsync(MockData.Where(a => a.UserId == userId)); var controller = new PhotoAlbumsController(mockRepo.Object); var result = await controller.GetAsync(userId); Assert.IsTrue(result.SelectMany(a => a.Photos).Any()); }
public async Task GetAsync_ReturnsPhotoAlbums() { var mockRepo = new Mock <IPhotoAlbumRepository>(); var userId = 1; mockRepo .Setup(repo => repo.GetPhotoAlbumsAsync(userId)) .ReturnsAsync(MockData.Where(a => a.UserId == userId)); var controller = new PhotoAlbumsController(mockRepo.Object); var result = await controller.GetAsync(userId); Assert.AreEqual(2, result.Count()); }