AWSGameLiftCreateSessionOnQueueActivityTest.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AWSGameLiftClientFixture.h>
  9. #include <Activity/AWSGameLiftCreateSessionOnQueueActivity.h>
  10. #include <aws/gamelift/model/StartGameSessionPlacementRequest.h>
  11. using namespace AWSGameLift;
  12. using AWSGameLiftCreateSessionOnQueueActivityTest = AWSGameLiftClientFixture;
  13. TEST_F(AWSGameLiftCreateSessionOnQueueActivityTest, BuildAWSGameLiftCreateGameSessionRequest_Call_GetExpectedResult)
  14. {
  15. AWSGameLiftCreateSessionOnQueueRequest request;
  16. request.m_sessionName = "dummySessionName";
  17. request.m_maxPlayer = 1;
  18. request.m_sessionProperties.emplace("dummyKey", "dummyValue");
  19. request.m_queueName = "dummyQueueName";
  20. request.m_placementId = "dummyPlacementId";
  21. auto awsRequest = CreateSessionOnQueueActivity::BuildAWSGameLiftStartGameSessionPlacementRequest(request);
  22. EXPECT_TRUE(strcmp(awsRequest.GetGameSessionName().c_str(), request.m_sessionName.c_str()) == 0);
  23. EXPECT_TRUE(awsRequest.GetMaximumPlayerSessionCount() == request.m_maxPlayer);
  24. EXPECT_TRUE(strcmp(awsRequest.GetGameProperties()[0].GetKey().c_str(), request.m_sessionProperties.begin()->first.c_str()) == 0);
  25. EXPECT_TRUE(strcmp(awsRequest.GetGameProperties()[0].GetValue().c_str(), request.m_sessionProperties.begin()->second.c_str()) == 0);
  26. EXPECT_TRUE(strcmp(awsRequest.GetGameSessionQueueName().c_str(), request.m_queueName.c_str()) == 0);
  27. EXPECT_TRUE(strcmp(awsRequest.GetPlacementId().c_str(), request.m_placementId.c_str()) == 0);
  28. }
  29. TEST_F(AWSGameLiftCreateSessionOnQueueActivityTest, ValidateCreateSessionOnQueueRequest_CallWithBaseType_GetFalseResult)
  30. {
  31. auto result = CreateSessionOnQueueActivity::ValidateCreateSessionOnQueueRequest(Multiplayer::CreateSessionRequest());
  32. EXPECT_FALSE(result);
  33. }
  34. TEST_F(AWSGameLiftCreateSessionOnQueueActivityTest, ValidateCreateSessionOnQueueRequest_CallWithNegativeMaxPlayer_GetFalseResult)
  35. {
  36. AWSGameLiftCreateSessionOnQueueRequest request;
  37. request.m_maxPlayer = std::numeric_limits<uint64_t>::max();
  38. auto result = CreateSessionOnQueueActivity::ValidateCreateSessionOnQueueRequest(request);
  39. EXPECT_FALSE(result);
  40. }
  41. TEST_F(AWSGameLiftCreateSessionOnQueueActivityTest, ValidateCreateSessionOnQueueRequest_CallWithoutQueueName_GetFalseResult)
  42. {
  43. AWSGameLiftCreateSessionOnQueueRequest request;
  44. request.m_maxPlayer = 1;
  45. request.m_placementId = "dummyPlacementId";
  46. auto result = CreateSessionOnQueueActivity::ValidateCreateSessionOnQueueRequest(request);
  47. EXPECT_FALSE(result);
  48. }
  49. TEST_F(AWSGameLiftCreateSessionOnQueueActivityTest, ValidateCreateSessionOnQueueRequest_CallWithoutPlacementId_GetFalseResult)
  50. {
  51. AWSGameLiftCreateSessionOnQueueRequest request;
  52. request.m_maxPlayer = 1;
  53. request.m_queueName = "dummyQueueName";
  54. auto result = CreateSessionOnQueueActivity::ValidateCreateSessionOnQueueRequest(request);
  55. EXPECT_FALSE(result);
  56. }
  57. TEST_F(AWSGameLiftCreateSessionOnQueueActivityTest, ValidateCreateSessionOnQueueRequest_CallWithValidRequest_GetTrueResult)
  58. {
  59. AWSGameLiftCreateSessionOnQueueRequest request;
  60. request.m_maxPlayer = 1;
  61. request.m_queueName = "dummyQueueName";
  62. request.m_placementId = "dummyPlacementId";
  63. auto result = CreateSessionOnQueueActivity::ValidateCreateSessionOnQueueRequest(request);
  64. EXPECT_TRUE(result);
  65. }