public async void Delete_ValidId_Unauthorized()
        {
            //ARRANGE: Get a valid and existing privateSongId
            string privateSongId = MySqlHelpers.GetRandomUserPrivateSongId("Anabela");

            //ACT:
            string responseContentString = await Delete_Act(privateSongId, HttpStatusCode.Unauthorized);

            //ASSERT: Correct Response Object
            Assert.Equal("", responseContentString);
        }
        public async void GetInfo_Unauthorized()
        {
            //ARRANGE: Get a valid and existing privateSongId
            string privateSongId = MySqlHelpers.GetRandomUserPrivateSongId("Miguel");

            //ACT:
            string responseContentString = await GetInfo_Act(privateSongId, HttpStatusCode.Unauthorized);

            //ASSERT: Correct response object
            Assert.Equal("", responseContentString);
        }
Ejemplo n.º 3
0
        public async void Edit_Valid_Unauthorized()
        {
            //ARRANGE: Get a valid and existing privateSongId
            string privateSongId = MySqlHelpers.GetRandomUserPrivateSongId("Anabela");

            //ARRANGE: Set a privateSong model with the new info for the song
            PrivateSongBM model = ValidModelForEdit;

            //ACT:
            string responseContentString = await Edit_Act(privateSongId, model, HttpStatusCode.Unauthorized);

            //ASSERT: Correct response object
            Assert.Equal("", responseContentString);
        }
Ejemplo n.º 4
0
        public async void Edit_InvalidModel(PrivateSongBM model)
        {
            //ARRANGE: authenticate user
            MyUser user = fixture.Authenticate_User("Anabela");

            //ARRANGE: Get a valid and existing privateSongId
            string privateSongId = MySqlHelpers.GetRandomUserPrivateSongId(user.UserName);

            //ACT:
            string responseContentString = await Edit_Act(privateSongId, model, HttpStatusCode.BadRequest);

            //ASSERT: Correct response object
            Assert.Equal("", responseContentString);
        }
        public async void GetInfo_Authenticated()
        {
            //ARRANGE: authenticate user
            MyUser user = fixture.Authenticate_User("Miguel");

            //ARRANGE: Get a valid and existing privateSongId
            string privateSongId = MySqlHelpers.GetRandomUserPrivateSongId(user.UserName);

            //ACT:
            string responseContentString = await GetInfo_Act(privateSongId, HttpStatusCode.OK);

            //ASSERT: Response object matches database state
            PrivateSongBM responseObject =
                JsonConvert.DeserializeObject <PrivateSongBM>(responseContentString);

            Assert.True(MySqlHelpers.CheckIfPrivateSongBmMatchesDb(privateSongId, responseObject));
        }
Ejemplo n.º 6
0
        public async void Edit_Valid()
        {
            //ARRANGE: authenticate user
            MyUser user = fixture.Authenticate_User("Anabela");

            //ARRANGE: Get a valid and existing privateSongId
            string privateSongId = MySqlHelpers.GetRandomUserPrivateSongId(user.UserName);

            //ARRANGE: Set a privateSong model with the new info for the song
            PrivateSongBM model = ValidModelForEdit;

            //ACT:
            string responseContentString = await Edit_Act(privateSongId, model, HttpStatusCode.OK);

            //ASSERT: Correct response object
            PrivateSongBasicVM responseObject = JsonConvert.DeserializeObject <PrivateSongBasicVM>(responseContentString);

            Assert.Equal(model.Name, responseObject.Name);
            Assert.Equal(privateSongId, responseObject.PrivateSongId);
            Assert.True(Guid.TryParse(responseObject.SongId, out Guid auxSongId));


            //ASSERT: Correct database state

            Song expected = new Song();

            expected.SongId = auxSongId;

            expected.PrivateSong = new PrivateSong();
            expected.PrivateSong.PrivateSongId = Guid.Parse(privateSongId);
            expected.PrivateSong.Name          = model.Name;
            expected.PrivateSong.ArtistName    = model.ArtistName;
            expected.PrivateSong.AlbumName     = model.AlbumName;
            expected.PrivateSong.MyUser        = user;

            expected.Video          = new Video();
            expected.Video.VideoUrl = model.VideoUrl;
            expected.Video.StartSec = Video.GetTimeInSeconds(model.StartAt);
            expected.Video.EndSec   = Video.GetTimeInSeconds(model.EndAt);
            expected.Video.Duration = Video.GetDuration(expected.Video.StartSec, expected.Video.EndSec);

            Assert.True(MySqlHelpers.CheckIfPrivateSongWasCreated(expected, true));
        }
        public async void Delete_ValidId()
        {
            //ARRANGE: authenticate user
            MyUser user = fixture.Authenticate_User("Anabela");

            //ARRANGE: Get a valid and existing privateSongId
            string privateSongId = MySqlHelpers.GetRandomUserPrivateSongId(user.UserName);

            //ACT:
            string responseContentString = await Delete_Act(privateSongId, HttpStatusCode.OK);

            //ASSERT: Correct Response Object
            PrivateSongBasicVM responseObject = JsonConvert.DeserializeObject <PrivateSongBasicVM>(responseContentString);

            Assert.Null(responseObject.Name);
            Assert.Equal(privateSongId, responseObject.PrivateSongId);
            Assert.True(Guid.TryParse(responseObject.SongId, out Guid auxSongId));

            //ASSERT: Correct Database State
            Assert.True(MySqlHelpers.CheckIfPrivateSongWasDeleted(privateSongId));
        }