예제 #1
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));
        }
예제 #2
0
        public async void Create_ValidModel(PrivateSongBM model)
        {
            //ARRANGE: authenticate user
            MyUser user = fixture.Authenticate_User("Miguel");

            //ACT
            string responseContentString = await Create_Act(model, HttpStatusCode.OK);

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

            Assert.Equal(model.Name, responseObject.Name);
            Assert.True(Guid.TryParse(responseObject.PrivateSongId, out Guid auxPrivateSongId));
            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 = auxPrivateSongId;
            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));
        }