Пример #1
0
        public void ShouldUpdateProfile()
        {
            SqlLiteDatabaseTest(options =>
            {
                var playListService = _server.Host.Services.GetService(typeof(IProfileService)) as IProfileService;

                using (var context = new PlayCatDbContext(options))
                {
                    playListService.SetDbContext(context);

                    var user = context.CreateUser("*****@*****.**", "v", "last", "m", "123", "123");
                    context.SaveChanges();

                    string newFirstName = "newFirstName";
                    string newLastName  = "newLastName";
                    string newNickname  = "newNickName";
                    var result          = playListService.UpdateProfile(new DataService.Request.UpdateProfileRequest()
                    {
                        Id        = user.Id,
                        FirstName = newFirstName,
                        LastName  = newLastName,
                        NickName  = newNickname,
                    });

                    CheckIfSuccess(result);
                    Assert.NotNull(result.User);
                    Assert.Equal(newFirstName, result.User.FirstName);
                    Assert.Equal(newLastName, result.User.LastName);
                    Assert.Equal(newNickname, result.User.NickName);
                }
            });
        }
Пример #2
0
        public void ShouldSuccessReturnProfile()
        {
            SqlLiteDatabaseTest(options =>
            {
                var playListService = _server.Host.Services.GetService(typeof(IProfileService)) as IProfileService;

                using (var context = new PlayCatDbContext(options))
                {
                    playListService.SetDbContext(context);

                    string email      = "*****@*****.**";
                    string firstName  = "v";
                    string lastName   = "last";
                    string nickName   = "mef";
                    string password   = "******";
                    string inviteCode = "123";
                    var user          = context.CreateUser(email, firstName, lastName, nickName, password, inviteCode);
                    context.SaveChanges();

                    var result = playListService.GetProfile(user.Id);

                    CheckIfSuccess(result);
                    Assert.NotNull(result.User);
                    Assert.Equal(email, result.User.Email);
                    Assert.Equal(firstName, result.User.FirstName);
                    Assert.Equal(lastName, result.User.LastName);
                    Assert.Equal(nickName, result.User.NickName);
                }
            });
        }
Пример #3
0
        protected Guid GetUserId(PlayCatDbContext context)
        {
            string password = "******";
            string email    = "*****@*****.**";

            User      user      = context.CreateUser(email, "test", "test", "m", password);
            AuthToken authToken = context.CreateToken(DateTime.Now.AddDays(-1), false, user.Id);

            context.SaveChanges();

            return(user.Id);
        }
Пример #4
0
        private new Guid GetUserId(PlayCatDbContext context)
        {
            string password = "******";
            string email    = "*****@*****.**";

            User      user      = context.CreateUser(email, "test", "test", "m", password);
            Playlist  playlist  = context.CreatePlaylist(true, user.Id, "General", 0);
            AuthToken authToken = context.CreateToken(DateTime.Now.AddDays(-1), false, user.Id);

            context.SaveChanges();

            return(user.Id);
        }
Пример #5
0
        protected Guid GetUserId(PlayCatDbContext context)
        {
            var inviteService = _server.Host.Services.GetService(typeof(IInviteService)) as IInviteService;

            string password = "******";
            string email    = "*****@*****.**";

            DataModel.User      user      = context.CreateUser(email, "test", "test", "m", password, inviteService.GenerateInvite());
            DataModel.AuthToken authToken = context.CreateToken(DateTime.Now.AddDays(-1), false, user.Id);

            context.SaveChanges();

            return(user.Id);
        }
Пример #6
0
        public void ShouldFailGetProfileOnWrongId()
        {
            SqlLiteDatabaseTest(options =>
            {
                var playListService = _server.Host.Services.GetService(typeof(IProfileService)) as IProfileService;

                using (var context = new PlayCatDbContext(options))
                {
                    playListService.SetDbContext(context);

                    var user = context.CreateUser("*****@*****.**", "v", "last", "m", "123", "123");
                    context.SaveChanges();

                    var result = playListService.GetProfile(Guid.Empty);

                    CheckIfFail(result);
                    Assert.True(result.Info.Any());
                }
            });
        }