AWSGameLiftCreateSessionActivityTest.cpp 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 <Activity/AWSGameLiftCreateSessionActivity.h>
  9. #include <AWSGameLiftClientFixture.h>
  10. #include <aws/gamelift/model/CreateGameSessionRequest.h>
  11. using namespace AWSGameLift;
  12. using AWSGameLiftCreateSessionActivityTest = AWSGameLiftClientFixture;
  13. TEST_F(AWSGameLiftCreateSessionActivityTest, BuildAWSGameLiftCreateGameSessionRequest_Call_GetExpectedResult)
  14. {
  15. AWSGameLiftCreateSessionRequest request;
  16. request.m_creatorId = "dummyCreatorId";
  17. request.m_sessionName = "dummySessionName";
  18. request.m_maxPlayer = 1;
  19. request.m_sessionProperties.emplace("dummyKey", "dummyValue");
  20. request.m_aliasId = "dummyAliasId";
  21. request.m_fleetId = "dummyFleetId";
  22. request.m_idempotencyToken = "dummyIdempotencyToken";
  23. auto awsRequest = CreateSessionActivity::BuildAWSGameLiftCreateGameSessionRequest(request);
  24. EXPECT_TRUE(strcmp(awsRequest.GetCreatorId().c_str(), request.m_creatorId.c_str()) == 0);
  25. EXPECT_TRUE(strcmp(awsRequest.GetName().c_str(), request.m_sessionName.c_str()) == 0);
  26. EXPECT_TRUE(awsRequest.GetMaximumPlayerSessionCount() == request.m_maxPlayer);
  27. EXPECT_TRUE(strcmp(awsRequest.GetGameProperties()[0].GetKey().c_str(), request.m_sessionProperties.begin()->first.c_str()) == 0);
  28. EXPECT_TRUE(strcmp(awsRequest.GetGameProperties()[0].GetValue().c_str(), request.m_sessionProperties.begin()->second.c_str()) == 0);
  29. EXPECT_TRUE(strcmp(awsRequest.GetAliasId().c_str(), request.m_aliasId.c_str()) == 0);
  30. EXPECT_TRUE(strcmp(awsRequest.GetFleetId().c_str(), request.m_fleetId.c_str()) == 0);
  31. EXPECT_TRUE(strcmp(awsRequest.GetIdempotencyToken().c_str(), request.m_idempotencyToken.c_str()) == 0);
  32. }
  33. TEST_F(AWSGameLiftCreateSessionActivityTest, ValidateCreateSessionRequest_CallWithBaseType_GetFalseResult)
  34. {
  35. auto result = CreateSessionActivity::ValidateCreateSessionRequest(Multiplayer::CreateSessionRequest());
  36. EXPECT_FALSE(result);
  37. }
  38. TEST_F(AWSGameLiftCreateSessionActivityTest, ValidateCreateSessionRequest_CallWithNegativeMaxPlayer_GetFalseResult)
  39. {
  40. AWSGameLiftCreateSessionRequest request;
  41. request.m_maxPlayer = std::numeric_limits<uint64_t>::max();
  42. auto result = CreateSessionActivity::ValidateCreateSessionRequest(request);
  43. EXPECT_FALSE(result);
  44. }
  45. TEST_F(AWSGameLiftCreateSessionActivityTest, ValidateCreateSessionRequest_CallWithoutAliasOrFleetId_GetFalseResult)
  46. {
  47. AWSGameLiftCreateSessionRequest request;
  48. request.m_maxPlayer = 1;
  49. auto result = CreateSessionActivity::ValidateCreateSessionRequest(request);
  50. EXPECT_FALSE(result);
  51. }
  52. TEST_F(AWSGameLiftCreateSessionActivityTest, ValidateCreateSessionRequest_CallWithAliasId_GetTrueResult)
  53. {
  54. AWSGameLiftCreateSessionRequest request;
  55. request.m_maxPlayer = 1;
  56. request.m_aliasId = "dummyAliasId";
  57. auto result = CreateSessionActivity::ValidateCreateSessionRequest(request);
  58. EXPECT_TRUE(result);
  59. }
  60. TEST_F(AWSGameLiftCreateSessionActivityTest, ValidateCreateSessionRequest_CallWithFleetId_GetTrueResult)
  61. {
  62. AWSGameLiftCreateSessionRequest request;
  63. request.m_maxPlayer = 1;
  64. request.m_fleetId = "dummyFleetId";
  65. auto result = CreateSessionActivity::ValidateCreateSessionRequest(request);
  66. EXPECT_TRUE(result);
  67. }