public void GetAllPublicUserInfoTest()
        {
            // get all public user profile
            var firstCount = ProfileAccess.GetAllPublicUserInfos().Count;

            //create new public user
            UserAccess.Register(DefaultUser.Username + "1", DefaultUser.Password);

            var secondCount = ProfileAccess.GetAllPublicUserInfos().Count;

            Assert.AreEqual(firstCount + 1, secondCount);

            // not access to private user profile
            var profile = ProfileAccess.GetUserProfile();

            profile.IsPrivate = true;
            ProfileAccess.UpdateUserProfile(profile);

            var thirdCount = ProfileAccess.GetAllPublicUserInfos().Count;

            Assert.AreEqual(firstCount, thirdCount);

            // Delete user
            UserAccess.DeleteUser();
        }
示例#2
0
        public void DeleteOtherPlayerGameTest()
        {
            // create new user and game
            var userToken = "";

            try
            {
                userToken = UserAccess.Register(DefaultUser.Username + "1", DefaultUser.Password);
            }
            catch
            {
                userToken = UserAccess.Login(DefaultUser.Username + "1", DefaultUser.Password);
            }

            UserAccess.DeleteUser();
            var game = GameAccess.CreateGame(DefaultGame);

            try
            {
                // login as default user
                UserAccess.Login(DefaultUser.Username, DefaultUser.Password);
                GameAccess.DeleteGame(game.HashId);
                Assert.Fail();
            }
            catch
            {
                // login as good user to delete game
                FrontEndAccess.UserToken.Token = userToken;
                GameAccess.DeleteGame(game.HashId);
            }
        }
        public void ListOtherPlayerZonesTest()
        {
            // create new player and one map
            var token = "";

            try
            {
                token = UserAccess.Register(DefaultUser.Username + "1", DefaultUser.Password);
            }
            catch
            {
                token = UserAccess.Login(DefaultUser.Username + "1", DefaultUser.Password);
            }
            var decodedToken = JwtHelper.DecodeToken(token);
            var mapHashId    = ZoneAccess.CreateMap(DefaultZone.Name, DefaultZone.Content, DefaultZone.Level);

            UserToken.Token = Token;
            var maps = ZoneAccess.GetPlayerZones(decodedToken.UserId);

            Assert.AreEqual(1, maps.Count);
            Assert.AreEqual(DefaultZone.Name, maps[0].Name);

            // login as user to delete map and user
            UserToken.Token = token;
            ZoneAccess.DeleteMap(mapHashId);
            UserAccess.DeleteUser();
        }
        public void ListPublicUsermapsTest()
        {
            var firstCount = ZoneAccess.GetPublicZones().Count;

            // create map
            var mapHashId   = ZoneAccess.CreateMap(DefaultZone.Name, DefaultZone.Content, DefaultZone.Level);
            var myMaps      = ZoneAccess.GetMyZones().Count;
            var secondCount = ZoneAccess.GetPublicZones().Count;

            //Assert.AreEqual(firstCount+1, myMaps);
            Assert.AreEqual(firstCount + 1, secondCount);

            //create new public user
            try
            {
                UserToken.Token = UserAccess.Register(DefaultUser.Username + "1", DefaultUser.Password);
            }
            catch
            {
                UserToken.Token = UserAccess.Login(DefaultUser.Username + "1", DefaultUser.Password);
            }

            var zones = ZoneAccess.GetPublicZones();

            Assert.AreEqual(secondCount, zones.Count);

            // delete new user
            UserAccess.DeleteUser();


            // Delete Map
            UserToken.Token = Token;
            ZoneAccess.DeleteMap(mapHashId);
        }
示例#5
0
        public void Cleanup()
        {
            FrontEndAccess.UserToken.Token = Token;
            UserAccess.DeleteUser();

            FrontEndAccess.UserToken.Token = OtherUserToken;
            UserAccess.DeleteUser();
        }
        public void RegisterTest()
        {
            // register only with credentials
            var result = _userAccess.Register(_defaultUser.Username, _defaultUser.Password, "");

            _userAccess.UserToken = result;
            _userAccess.DeleteUser();
        }
示例#7
0
        public void Cleanup()
        {
            // Delete facebook user
            UserToken.Token = FacebookUserToken;
            UserAccess.DeleteUser();

            // Delete App user
            UserToken.Token = AppUserToken;
            UserAccess.DeleteUser();
        }
 public void RegisterWithValidFacebookUserTest()
 {
     try
     {
         UserAccess.Register(DefaultUser.Username, "", DefaultUser.FacebookId);
         UserAccess.DeleteUser();
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
 public void RegisterWithValidAppUserTest()
 {
     try
     {
         UserAccess.Register(DefaultUser.Username, DefaultUser.Password);
         UserAccess.DeleteUser();
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
        public void Initialize()
        {
            try
            {
                // If user already exist, delete him
                UserAccess.Login(DefaultUser.Username, DefaultUser.Password);
                UserAccess.DeleteUser();
            }
            catch
            {

            }
        }
 public void RegisterWithExistingAppUserTest()
 {
     UserAccess.Register(DefaultUser.Username, DefaultUser.Password);
     try
     {
         UserAccess.Register(DefaultUser.Username, DefaultUser.Password);
         Assert.Fail();
     }
     catch
     {
     }
     UserAccess.DeleteUser();
 }
 public void RegisterWithExistingFacebookUserTest()
 {
     UserToken.Token = UserAccess.Register(DefaultUser.Username, "", DefaultUser.FacebookId);
     try
     {
         UserAccess.Register(DefaultUser.Username, "", DefaultUser.FacebookId);
         Assert.Fail();
     }
     catch (Exception)
     {
     }
     UserAccess.DeleteUser();
 }
        public void ListFriendsZonesTest()
        {
            // create map
            var mapHashId    = ZoneAccess.CreateMap(DefaultZone.Name, DefaultZone.Content, DefaultZone.Level);
            var decodedToken = JwtHelper.DecodeToken(Token);


            //create new public user
            try
            {
                UserToken.Token = UserAccess.Register(DefaultUser.Username + "1", DefaultUser.Password);
            }
            catch
            {
                UserToken.Token = UserAccess.Login(DefaultUser.Username + "1", DefaultUser.Password);
            }

            var zones = ZoneAccess.GetMyFriendsZones();

            Assert.AreEqual(0, zones.Count);

            // Add user as friend
            var friendsList = new List <BasicUserInfo>
            {
                new BasicUserInfo()
                {
                    HashId   = decodedToken.UserId,
                    Username = decodedToken.Username
                }
            };

            FriendAccess.UpdateFriends(friendsList);

            zones = ZoneAccess.GetMyFriendsZones();
            Assert.AreEqual(1, zones.Count);

            // delete new user
            UserAccess.DeleteUser();


            // Delete Map
            UserToken.Token = Token;
            ZoneAccess.DeleteMap(mapHashId);
        }
示例#14
0
    protected void List_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int userId = Int32.Parse(AdminList.DataKeys[e.RowIndex].Value.ToString());

        bool success = UserAccess.DeleteUser(userId);

        if (success)
        {
            Utility.Alert(this, "删除成功。");
        }
        else
        {
            Utility.Alert(this, "删除失败!");
            return;
        }

        AdminList.EditIndex = -1;
        SwitchData();
    }
        public void Initialize()
        {
            _userAccess  = new UserAccess(Endpoint);
            _defaultUser = new UserModel()
            {
                FacebookId = "ad8c0aca0-9d0-ad-a0mxa-mxaxad",
                Username   = "******",
                Password   = "******"
            };

            try
            {
                // if user exist, delete it
                _userAccess.UserToken = _userAccess.Login(_defaultUser.Username, _defaultUser.Password, "");
                _userAccess.DeleteUser();
            }
            catch (Exception)
            {
            }
        }
        public void ListPublicuserMapsPrivateMapTest()
        {
            var firstCount = ZoneAccess.GetPublicZones().Count;

            // set private user
            var profile = ProfileAccess.GetUserProfile();

            // modify profile
            profile.IsPrivate = true;
            ProfileAccess.UpdateUserProfile(profile);

            // create map
            var mapHashId = ZoneAccess.CreateMap(DefaultZone.Name, DefaultZone.Content, DefaultZone.Level);

            //create new public user
            try
            {
                UserToken.Token = UserAccess.Register(DefaultUser.Username + "1", DefaultUser.Password);
            }
            catch
            {
                UserToken.Token = UserAccess.Login(DefaultUser.Username + "1", DefaultUser.Password);
            }

            var zones = ZoneAccess.GetPublicZones();

            Assert.AreEqual(firstCount, zones.Count);

            // delete new user
            UserAccess.DeleteUser();


            // Delete Map
            UserToken.Token = Token;
            ZoneAccess.DeleteMap(mapHashId);
        }
        public void AddFriendTest()
        {
            var userToken = "";

            try
            {
                userToken = UserAccess.Register(DefaultUser.Username + "1", DefaultUser.Password);
            }
            catch
            {
                userToken = UserAccess.Login(DefaultUser.Username + "1", DefaultUser.Password);
            }
            var decodedToken = JwtHelper.DecodeToken(userToken);

            // Add user as friend
            UserToken.Token = Token;
            var friendsList = new List <BasicUserInfo>
            {
                new BasicUserInfo()
                {
                    HashId   = decodedToken.UserId,
                    Username = decodedToken.Username
                }
            };

            FriendAccess.UpdateFriends(friendsList);

            // Verify the friend
            var friends = FriendAccess.GetFriends();

            Assert.AreEqual(1, friends.Count);

            // delete new user
            UserToken.Token = userToken;
            UserAccess.DeleteUser();
        }
        public void RegisterWithInvalidFacebookUserTest()
        {
            // No Username
            try
            {
                UserAccess.Register("", "", DefaultUser.FacebookId);
                UserAccess.DeleteUser();
                Assert.Fail();
            }
            catch (Exception)
            {
            }

            // No Facebook Id
            try
            {
                UserAccess.Register(DefaultUser.Username, "");
                UserAccess.DeleteUser();
                Assert.Fail();
            }
            catch (Exception)
            {
            }
        }
        public void RegisterWithInvalidAppUserTest()
        {
            // No Username
            try
            {
                UserAccess.Register("", DefaultUser.Password);
                UserAccess.DeleteUser();
                Assert.Fail();
            }
            catch
            {
            }

            // No Password
            try
            {
                UserAccess.Register(DefaultUser.Username, "");
                UserAccess.DeleteUser();
                Assert.Fail();
            }
            catch
            {
            }
        }
 public void Cleanup()
 {
     UserToken.Token = Token;
     UserAccess.DeleteUser();
 }
示例#21
0
 public void Cleanup()
 {
     ZoneAccess.DeleteMap(DefaultZone.HashId);
     UserToken.Token = Token;
     UserAccess.DeleteUser();
 }