AWSGameLiftAcceptMatchActivityTest.cpp 2.8 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 <aws/gamelift/model/AcceptMatchRequest.h>
  9. #include <AWSGameLiftClientFixture.h>
  10. #include <Activity/AWSGameLiftAcceptMatchActivity.h>
  11. #include <aws/gamelift/model/AcceptMatchRequest.h>
  12. using namespace AWSGameLift;
  13. using AWSGameLiftAcceptMatchActivityTest = AWSGameLiftClientFixture;
  14. TEST_F(AWSGameLiftAcceptMatchActivityTest, BuildAWSGameLiftAcceptMatchRequest_Call_GetExpectedResult)
  15. {
  16. AWSGameLiftAcceptMatchRequest request;
  17. request.m_acceptMatch = true;
  18. request.m_ticketId = "dummyTicketId";
  19. request.m_playerIds = { "dummyPlayerId" };
  20. auto awsRequest = AcceptMatchActivity::BuildAWSGameLiftAcceptMatchRequest(request);
  21. EXPECT_EQ(awsRequest.GetAcceptanceType(), Aws::GameLift::Model::AcceptanceType::ACCEPT);
  22. EXPECT_TRUE(strcmp(awsRequest.GetTicketId().c_str(), request.m_ticketId.c_str()) == 0);
  23. EXPECT_EQ(awsRequest.GetPlayerIds().size(), request.m_playerIds.size());
  24. EXPECT_TRUE(strcmp(awsRequest.GetPlayerIds().begin()->c_str(), request.m_playerIds.begin()->c_str()) == 0);
  25. }
  26. TEST_F(AWSGameLiftAcceptMatchActivityTest, ValidateAcceptMatchRequest_CallWithBaseType_GetFalseResult)
  27. {
  28. AZ_TEST_START_TRACE_SUPPRESSION;
  29. auto result = AcceptMatchActivity::ValidateAcceptMatchRequest(Multiplayer::AcceptMatchRequest());
  30. EXPECT_FALSE(result);
  31. AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
  32. }
  33. TEST_F(AWSGameLiftAcceptMatchActivityTest, ValidateAcceptMatchRequest_CallWithoutTicketId_GetFalseResult)
  34. {
  35. AWSGameLiftAcceptMatchRequest request;
  36. request.m_acceptMatch = true;
  37. request.m_playerIds = { "dummyPlayerId" };
  38. AZ_TEST_START_TRACE_SUPPRESSION;
  39. auto result = AcceptMatchActivity::ValidateAcceptMatchRequest(request);
  40. EXPECT_FALSE(result);
  41. AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
  42. }
  43. TEST_F(AWSGameLiftAcceptMatchActivityTest, ValidateAcceptMatchRequest_CallWithoutPlayerIds_GetFalseResult)
  44. {
  45. AWSGameLiftAcceptMatchRequest request;
  46. request.m_acceptMatch = true;
  47. request.m_playerIds = { "dummyPlayerId" };
  48. AZ_TEST_START_TRACE_SUPPRESSION;
  49. auto result = AcceptMatchActivity::ValidateAcceptMatchRequest(request);
  50. EXPECT_FALSE(result);
  51. AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
  52. }
  53. TEST_F(AWSGameLiftAcceptMatchActivityTest, ValidateAcceptMatchRequest_CallWithValidAttributes_GetTrueResult)
  54. {
  55. AWSGameLiftAcceptMatchRequest request;
  56. request.m_acceptMatch = true;
  57. request.m_ticketId = "dummyTicketId";
  58. request.m_playerIds = { "dummyPlayerId" };
  59. auto result = AcceptMatchActivity::ValidateAcceptMatchRequest(request);
  60. EXPECT_TRUE(result);
  61. }