Exemplo n.º 1
0
        public void Should_Throw_BadRequest_If_There_Is_An_Exception()
        {
            ObjectId objectId = new ObjectId();

            _mockedSongRepository.Setup(x => x.GetById(It.IsAny <ObjectId>())).Throws(new Exception());

            var exception = Assert.Throws <HttpResponseException>(() => _songController.Get(objectId));

            exception.Response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }
Exemplo n.º 2
0
        public void Get_Returns_Two_Songs()
        {
            var expectedSongs = new List <Song>()
            {
                new Song(1, "string1", "string2"),
                new Song(2, "string3", "string4")
            };

            songRepo.GetAll().Returns(expectedSongs);

            var result      = underTest.Get();
            var countOfSong = result.Count();

            Assert.Equal(2, countOfSong);
        }
Exemplo n.º 3
0
        public async Task GetAllTest()
        {
            await controller.Create(new Song()
            {
                Name = "GetAllSong", UserId = "1"
            });

            await controller.Create(new Song()
            {
                Name = "GetAllSong", UserId = "1"
            });

            await controller.Create(new Song()
            {
                Name = "GetAllSong", UserId = "1"
            });

            var actual = await controller.Get();

            Assert.IsType <OkObjectResult>(actual);
            OkObjectResult result2 = actual as OkObjectResult;
            var            items   = result2.Value as List <Song>;

            Assert.True(items.Count >= 3);
        }
        public void Get_Returns_Count_Of_Songs()
        {
            // arrange
            var expectedSongs = new List <Song>()
            {
                new Song(1, "Sigh No More", "link.html", "3:30"),
                new Song(2, "Test Song", "testlink.html", "test")
            };

            //songList
            songMockRepo.GetAll().Returns(expectedSongs);

            // act
            var result         = testController.Get();
            var countOfArtists = result.Count();

            // assert
            Assert.Equal(2, countOfArtists);
        }
Exemplo n.º 5
0
        public void Get_Returns_List_of_Songs()
        {
            var expectedSong = new List <Songs>()
            {
                new Songs(1, "First song", "duration", 1),
                new Songs(1, "Second song", "duration", 1),
            };

            songRepo.GetAll().Returns(expectedSong);

            var result = underTest.Get();

            Assert.Equal(expectedSong, result.ToList());
        }
        public void Get_Returns_List_of_Songs()
        {
            var expectedSongs = new List <Song>()
            {
                new Song(1, "Title", "Link", "Time", 1, "./css/images/genericsong.jpg"),
                new Song(1, "Title", "Link", "Time", 1, "./css/images/genericsong.jpg")
            };

            songRepo.GetAll().Returns(expectedSongs);

            var result = underTest.Get();

            Assert.Equal(expectedSongs, result.ToList());
        }
        public void Get_Returns_List_Of_Songs()
        {
            var expectedSongs = new List <Song>()
            {
                new Song(1, "In My Dreams"),
                new Song(2, "Soundtrack 2 My Life")
            };

            songRepo.GetAll().Returns(expectedSongs);

            var result = underTest.Get();

            Assert.Equal(expectedSongs, result.ToList());
        }
Exemplo n.º 8
0
        public async void GetAllSongsTest()
        {
            DbContextOptions <MusicDbContext> options =
                new DbContextOptionsBuilder <MusicDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;

            using (MusicDbContext context = new MusicDbContext(options))
            {
                // Arrange
                Playlist playlist = new Playlist()
                {
                    Name = "test"
                };
                await context.Playlists.AddAsync(playlist);

                await context.SaveChangesAsync();

                Song song = new Song()
                {
                    Name        = "Shake It Off",
                    Artist      = "Taylor Swift",
                    Album       = "1989",
                    Genre       = "Pop",
                    ReleaseDate = DateTime.Today,
                    PlaylistID  = 1
                };
                SongController sc = new SongController(context);
                await context.Songs.AddAsync(song);

                await context.SaveChangesAsync();

                // Act
                var result = sc.Get();

                // Assert
                Assert.Equal(context.Songs, result);
            }
        }
Exemplo n.º 9
0
        public void Should_Return_List_SongVM_Properly()
        {
            List <SongVM> songVMList = new List <SongVM>()
            {
                new SongVM()
                {
                    Id          = new ObjectId(),
                    DisplayName = "test1",
                    AlbumId     = new ObjectId(),
                    ArtistId    = new ObjectId()
                }
            };

            var songs = new List <Song>()
            {
                new Song()
                {
                    Id          = new ObjectId(),
                    DisplayName = "test1",
                    AlbumId     = new ObjectId(),
                    ArtistId    = new ObjectId()
                }
            }.AsQueryable();

            _mockedSongRepository.Setup(x => x.GetAll()).Returns(songs);

            var result = _songController.Get();

            result[0].DisplayName.Should().Be(songVMList[0].DisplayName);

            result[0].Id.Should().Be(songVMList[0].Id);

            result[0].ArtistId.Should().Be(songVMList[0].ArtistId);

            result[0].AlbumId.Should().Be(songVMList[0].AlbumId);
        }
    public void GetbySlc_WhenSlcCalled_ReturnsASong()
    {
        var songResult = _controller.Get(3);

        Assert.IsType <Task <IActionResult> >(songResult);
    }
Exemplo n.º 11
0
        public void GetAllSongs()
        {
            var totalSongs = controller.Get();

            Assert.AreEqual(1, totalSongs.Count());
        }