Exemple #1
0
        public void ClaimingAReservationOnAReservedBridgeShouldMakeItConnected()
        {
            //When
            clientBridge.Connect(TestConstants.TEST_IP_ADDRESS, TestConstants.TEST_PLAYER_NAME);
            clientBridge.ConfirmReservation(correlationId, TestConstants.TEST_RESERVATION_KEY);
            clientBridge.ClaimReservation();

            //Then
            clientBridge.CurrentState.Should().Be(ClientBridgeState.Connected);
        }
        public void Start(string ip)
        {
            ClientBridge.Connect(ip, playerName);

            var iterations = 0;

            do
            {
                Thread.Sleep(250);
                ProcessPackets();

                iterations++;
                if (iterations >= 20)
                {
                    break;
                }
            } while (ClientBridge.CurrentState == ClientBridgeState.WaitingForRerservation);

            switch (ClientBridge.CurrentState)
            {
            case ClientBridgeState.Reserved:
                ClientBridge.ClaimReservation();
                Log.InGame("Connected to server");
                break;

            default:
                Log.InGame("Unable to connect to server");
                break;
            }
        }
        public void ShouldThrowAProhibitedConnectAttemptExceptionWhenConnectIsCalledOnAConnectedBridge()
        {
            //When
            clientBridge.ConfirmReservation(correlationId, TestConstants.TEST_RESERVATION_KEY);
            clientBridge.ClaimReservation();
            Action action = () => clientBridge.Connect(TestConstants.TEST_IP_ADDRESS, TestConstants.TEST_PLAYER_NAME);

            //Then
            action.ShouldThrow <ProhibitedConnectAttemptException>();
        }
        public void TheBridgeShouldThrowAProhibitedReservationRejectionExceptionWhenHandlingAReservationRejectionAfterOneHasBeenClaimed()
        {
            //When
            clientBridge.Connect(TestConstants.TEST_IP_ADDRESS, TestConstants.TEST_PLAYER_NAME);
            clientBridge.ConfirmReservation(correlationId, TestConstants.TEST_RESERVATION_KEY);
            clientBridge.ClaimReservation();
            Action action = () => clientBridge.HandleRejectedReservation(correlationId, TestConstants.TEST_REJECTION_STATE);

            //Then
            action.ShouldThrow <ProhibitedReservationRejectionException>();
        }
Exemple #5
0
        public void ShouldBeAbleToSendAPacketThroughAConnectedClientBridge()
        {
            //When
            clientBridge.Connect(TestConstants.TEST_IP_ADDRESS, TestConstants.TEST_PLAYER_NAME);
            clientBridge.ConfirmReservation(correlationId, TestConstants.TEST_RESERVATION_KEY);
            clientBridge.ClaimReservation();

            clientBridge.Send(packet);

            //Then
            serverClient.Received().Send(Arg.Is(packet));
        }
        public void TheBridgeShouldThrowAnInvalidReservationExceptionIfConfirmingAReserverationWhileItIsAlreadyConnected()
        {
            //When
            clientBridge.Connect(TestConstants.TEST_IP_ADDRESS, TestConstants.TEST_PLAYER_NAME);
            clientBridge.ConfirmReservation(correlationId, TestConstants.TEST_RESERVATION_KEY);
            clientBridge.ClaimReservation();
            Action action = () => clientBridge.ConfirmReservation(null, null);

            //Then
            action.ShouldThrow <InvalidReservationException>();
            clientBridge.CurrentState.Should().Be(ClientBridgeState.Failed);
        }
 public void JoinSession()
 {
     OnBeforeMultiplayerStart();
     clientBridge.ClaimReservation();
     InitMonoBehaviours();
 }