Ejemplo n.º 1
0
 /// <summary>
 /// does the pot action for the table specified
 /// </summary>
 /// <param name="table">the table(API)</param>
 private static void postAPICall(string table)
 {
     if (table.Equals("songs"))
     {
         Assignment2.song s      = getSongPostInfo();
         SongsController  cont   = new SongsController();
         string           result = cont.PostSong(s);
         Console.WriteLine(result);
     }
     else if (table.Equals("reviews"))
     {
         Assignment2.review r      = getReviewPostInfo();
         ReviewsController  cont   = new ReviewsController();
         string             result = cont.PostReview(r);
         Console.WriteLine(result);
     }
 }
Ejemplo n.º 2
0
        public async Task CanPostSong()
        {
            var song = new Song
            {
                Duration = TimeSpan.FromSeconds(100),
                Id       = 4,
                Lyrics   = "lyrics",
                Rating   = 5,
                Title    = "Song11"
            };

            var result = await _controller.PostSong(song);

            var okResult   = result.Should().BeOfType <CreatedAtActionResult>().Subject;
            var resultSong = okResult.Value.Should().BeAssignableTo <Song>().Subject;

            resultSong.Id.Should().Be(song.Id);
        }
            public void Post_Creates_New_Song()
            {
                // arrange
                var newSong  = new Song(1, "First Song", "3:12", "song.com", 1);
                var songList = new List <Song>();

                // Use When..Do to substitute for methods that don't return a value, like the Repository method Create()
                // When() allows us to call the method on the substitute and pass an argument
                // Do() allows us to pass a callback function that executes when the method is called
                songRepo.When(t => t.Create(newSong))
                .Do(t => songList.Add(newSong));

                songRepo.GetAll().Returns(songList);

                // act
                var result = underTest.PostSong(newSong);

                // assert
                Assert.Contains(newSong, result);
            }