public async Task CreateAlbumShouldCreateNewWallPost() { var post = new Post(); var postService = new Mock <IWallPostsService>(); postService .Setup(r => r.CreateAsync (It.IsAny <string>(), It.IsAny <PostType>(), It.IsAny <int?>(), It.IsAny <string>())) .Callback <string, PostType, int?, string>((c, t, a, o) => { post.UserId = c; post.PostType = t; post.AssignedEntity = a; post.Content = o; }); var service = new PhotoAlbumsService( this.albumRepository, this.pictureRepository, postService.Object, this.postRepository, this.cloudinaryService); await service.CreateAlbum("aaa", "bbb", null, "ccc"); Assert.Equal("ccc", post.UserId); Assert.Equal(PostType.NewPicture, post.PostType); Assert.Null(post.Content); }
public async Task CreateAlbumShouldCreateAlbum() { var albums = new List <Album>(); var repository = new Mock <IDeletableEntityRepository <Album> >(); repository .Setup(r => r.AddAsync(It.IsAny <Album>())) .Callback((Album a) => albums.Add(a)); var cloudService = new Mock <ICloudinaryService>(); cloudService.Setup(c => c.AddPhotoInAlbum(It.IsAny <int>(), It.IsAny <IFormFile>())); var service = new PhotoAlbumsService( repository.Object, this.pictureRepository, this.postsService, this.postRepository, cloudService.Object); await service.CreateAlbum("aaa", "bbb", null, "ccc"); Assert.Single(albums); Assert.Equal("aaa", albums[0].Title); Assert.Equal("bbb", albums[0].Description); Assert.Equal("ccc", albums[0].UserId); Assert.IsAssignableFrom <ICollection <Picture> >(albums[0].Pictures); }