/// <summary> /// Comparer function used to facilitate the check of whether two AlbumAndPhoto objects are Equal with regards to their Properties /// </summary> public bool IsPropertyWiseEqual(AlbumAndPhoto otherAlbumAndPhoto) { return(UserID == otherAlbumAndPhoto.UserID && AlbumID == otherAlbumAndPhoto.AlbumID && AlbumTitle == otherAlbumAndPhoto.AlbumTitle && PhotoID == otherAlbumAndPhoto.PhotoID && PhotoTitle == otherAlbumAndPhoto.PhotoTitle && PhotoUrl == otherAlbumAndPhoto.PhotoUrl && PhotoThumbnailUrl == otherAlbumAndPhoto.PhotoThumbnailUrl); }
public async Task AlbumsAndPhotosForUserControllerActionReturnsOkResultWithWhatTheAlbumsAndPhotosServiceReturnsOnlyForTheUser([Random(1, 100, 50)] int randomUserID) { // Arrange var albumAndPhotoForTest = new AlbumAndPhoto(randomUserID, 1, "", 1, "", "", ""); var albumsAndPhotosServiceMock = new Mock <IAlbumsAndPhotosService>(); albumsAndPhotosServiceMock.Setup(x => x.GetAlbumsAndPhotosForUserAsync(2)) .Returns(Task.FromResult(result: new List <AlbumAndPhoto>() { albumAndPhotoForTest } as IEnumerable <AlbumAndPhoto>)); var albumsAndPhotosController = new AlbumsAndPhotosController(albumsAndPhotosServiceMock.Object); // Act var result = await albumsAndPhotosController.GetAlbumsAndPhotosForUser(2); // Assert Assert.IsInstanceOf(typeof(OkObjectResult), result); Assert.IsInstanceOf(typeof(IEnumerable <AlbumAndPhoto>), (result as OkObjectResult).Value); Assert.AreEqual(((result as OkObjectResult).Value as IEnumerable <AlbumAndPhoto>).FirstOrDefault(), albumAndPhotoForTest); Assert.AreEqual(((result as OkObjectResult).Value as IEnumerable <AlbumAndPhoto>).All(x => x.UserID == randomUserID), true); }