Пример #1
0
        public void PlayersWhoRegisterWithTheSameDeviceIdCannotJoinTheSameGame()
        {
            string one = "DeviceOne";
            string two = "DeviceTwo";

            client.RegisterAccount(new AccountRegistrationRequest()
            {
                Username         = one,
                Password         = one,
                Email            = one,
                DeviceIdentifier = one,
            });

            client.RegisterAccount(new AccountRegistrationRequest()
            {
                Username         = two,
                Password         = two,
                Email            = two,
                DeviceIdentifier = one,
            });

            CreateRoomResponse createResponse = client.CreateNewRoom(new CreateRoomRequest()
            {
                RoomName   = "Room",
                MaxPlayers = 4,
                Goal       = Goal.Domination,
            });

            Assert.AreEqual(createResponse.Status.IsSuccess, true);
            var roomId = createResponse.CreatedRoom.RoomId;

            client.Login(new AuthorizationRequest()
            {
                Username = one,
                Password = one,
            });

            var exception = client.JoinRoom(new JoinRoomRequest()
            {
                RoomId = roomId
            });

            Assert.AreEqual(exception.Status.IsSuccess, false);
            Assert.AreEqual(exception.Status.Detail, ResponseType.PERMISSION_DENIED.ToString());
        }
        public void UserCanRegisterNewAccount()
        {
            String username = "******";
            String password = "******";

            AccountRegistrationRequest request = new AccountRegistrationRequest()
            {
                Email    = "*****@*****.**",
                Password = password,
                Username = username,
            };

            AccountRegistrationResponse response = client.RegisterAccount(request);

            Assert.IsTrue(response.Token != null);
            Assert.IsTrue(response.User.Id != null);
            Assert.AreEqual(response.User.Username, username);
        }
Пример #3
0
        public void PlayersWhoRegisterWithTheSameDeviceIdCannotJoinTheSameGame()
        {
            string one = "DeviceOne";
            string two = "DeviceTwo";

            client.RegisterAccount(new AccountRegistrationRequest()
            {
                Username         = one,
                Password         = one,
                Email            = one,
                DeviceIdentifier = one,
            });

            client.RegisterAccount(new AccountRegistrationRequest()
            {
                Username         = two,
                Password         = two,
                Email            = two,
                DeviceIdentifier = one,
            });

            var roomId = createRoom(maxPlayers: 4);

            client.Login(new AuthorizationRequest()
            {
                Username = one,
                Password = one,
            });

            var exception = client.JoinRoom(new JoinRoomRequest()
            {
                RoomId = roomId
            });

            assertResponseFailure(exception.Status, ResponseType.PERMISSION_DENIED);
        }
Пример #4
0
        public String createAccount(String username)
        {
            String pass = RandomString(13);

            AccountRegistrationRequest request = new AccountRegistrationRequest()
            {
                Email            = "*****@*****.**",
                Password         = pass,
                Username         = username,
                DeviceIdentifier = Guid.NewGuid().ToString(),
            };

            AccountRegistrationResponse response = client.RegisterAccount(request);

            userIds.Add(username, response.User.Id);
            accounts.Add(username, pass);
            return(response.User.Id);
        }