public void PostAlbum_Should_ReturnAlbumModel()
        {
            var albumModel = new AlbumAddModel {
                Name = "name", Description = "desc"
            };
            var albumDTO = new AlbumDTO {
                Name = "name", Description = "desc"
            };

            mockService.Setup(s => s.AddAlbumAsync(It.Is <AlbumAddDTO>(dto =>
                                                                       dto.Name == albumModel.Name && dto.Description == albumModel.Description))).ReturnsAsync(albumDTO).Verifiable();

            controller.PostAlbum(albumModel).Result.Result.Should().BeOfType <OkObjectResult>()
            .Which.Value.Should().BeEquivalentTo(albumModel);
            mockService.Verify();
        }
Пример #2
0
        public async Task <ActionResult <AlbumModel> > PostAlbum([FromBody] AlbumAddModel albumAddModel)
        {
            var albumAddDTO = mapper.Map <AlbumAddDTO>(albumAddModel, opt => opt.Items["userId"] = UserId);

            return(Ok(mapper.Map <AlbumModel>(await albumService.AddAlbumAsync(albumAddDTO))));
        }