Пример #1
0
        public async void TestCreateAlbumAsync()
        {
            // 2. Act: Run the SUT (Software Under Test - the actual testing code)
            var request = new AlbumViewModel
            {
                Name          = "DNA 2",
                Review        = @"2222 There's one question the Backsteet Boys can't seem to escape: Do they still consider themselves a boy band? The five-piece, most of whom are now over 40 and married with children, have come to embrace the term. ""At this point, 'boys' has come to mean more, like, 'friends'."" Kevin Richardson told...",
                Released      = DateTime.Parse("2020-01-22"),
                CopyRightInfo = "222 © 2018 K-Bahn, LLC & RCA Records, a division of Sony Music Entertainment",
                CoverPath     = "Uploads222/Pictures/Albums/Covers/DNA.png",
                MusicTypeId   = Guid.Parse("5befa4aa-06fd-4390-a2f5-a54600d4e3c2"),
                ArtistId      = Guid.Parse("5befa4aa-06fd-4390-a2f5-a54600d4e3a2"),
                AlbumPriceId  = Guid.Parse("1a178d0e-6602-4375-a088-ab8d00facaa1")
            };

            var data = await _controller.CreateAlbumAsync(request);

            // 3. Assert: Check and verify the result.
            Assert.IsAssignableFrom <IActionResult>(data);

            bool IsValid = (int)data.GetType().GetProperty("StatusCode").GetValue(data, null) == 200;

            Assert.True(IsValid);

            var album = (AlbumViewModel)data.GetType().GetProperty("Value").GetValue(data);

            IsValid = album.ErrorMessage?.FirstOrDefault() == null;
            Assert.True(IsValid);
        }
        public async void TestCreateAlbumAsync()
        {
            var request = new AlbumDto
            {
                Name          = "DNA 2",
                Review        = @"2222 There's one question the Backsteet Boys can't seem to escape: Do they still consider themselves a boy band? The five-piece, most of whom are now over 40 and married with children, have come to embrace the term. ""At this point, 'boys' has come to mean more, like, 'friends'."" Kevin Richardson told...",
                Released      = DateTime.Parse("2020-01-22"),
                CopyRightInfo = "222 © 2018 K-Bahn, LLC & RCA Records, a division of Sony Music Entertainment",
                CoverPath     = "Uploads222/Pictures/Albums/Covers/DNA.png",
                MusicTypeId   = Guid.Parse("5befa4aa-06fd-4390-a2f5-a54600d4e3c2"),
                ArtistId      = Guid.Parse("5befa4aa-06fd-4390-a2f5-a54600d4e3a2"),
                AlbumPriceId  = Guid.Parse("1a178d0e-6602-4375-a088-ab8d00facaa1")
            };

            var data = await _albumsController.CreateAlbumAsync(request);

            Assert.IsAssignableFrom <AlbumDto>(data);
            bool IsValid = data.ErrorMessage == null ? true : false;

            Assert.True(IsValid);
        }