public void NegotiateShouldThrowInvalidOperationExceptionWhenTheReservationIsNull() { // Arrange IMultiplayerSessionConnectionContext connectionContext = Substitute.For <IMultiplayerSessionConnectionContext>(); connectionContext.Reservation.Returns((MultiplayerSessionReservation)null); AwaitingSessionReservation connectionState = new AwaitingSessionReservation(TestConstants.TEST_CORRELATION_ID); // Act Action action = () => connectionState.NegotiateReservation(connectionContext); // Assert action.Should().Throw <InvalidOperationException>(); }
public void NegotiateShouldTransitionToSessionReservationRejectedAfterReceivingRejectedReservation() { // Arrange MultiplayerSessionReservation rejectedReservation = new MultiplayerSessionReservation(TestConstants.TEST_CORRELATION_ID, TestConstants.TEST_REJECTION_STATE); IMultiplayerSessionConnectionContext connectionContext = Substitute.For <IMultiplayerSessionConnectionContext>(); connectionContext.Reservation.Returns(rejectedReservation); AwaitingSessionReservation connectionState = new AwaitingSessionReservation(TestConstants.TEST_CORRELATION_ID); // Act connectionState.NegotiateReservation(connectionContext); // Assert connectionContext.Received().UpdateConnectionState(Arg.Any <SessionReservationRejected>()); }
public void NegotiateShouldThrowUncorrelatedPacketExceptionWhenTheReservationHasTheWrongCorrelationId() { // Arrange MultiplayerSessionReservation successfulReservation = new MultiplayerSessionReservation( "wrong", TestConstants.TEST_PLAYER_ID, TestConstants.TEST_RESERVATION_KEY); IMultiplayerSessionConnectionContext connectionContext = Substitute.For <IMultiplayerSessionConnectionContext>(); connectionContext.Reservation.Returns(successfulReservation); AwaitingSessionReservation connectionState = new AwaitingSessionReservation(TestConstants.TEST_CORRELATION_ID); // Act Action action = () => connectionState.NegotiateReservation(connectionContext); // Assert action.Should().Throw <UncorrelatedPacketException>(); }