123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #include <Multiplayer/Session/ISessionHandlingRequests.h>
- #include <AWSGameLiftClientFixture.h>
- #include <Activity/AWSGameLiftJoinSessionActivity.h>
- using namespace AWSGameLift;
- using AWSGameLiftJoinSessionActivityTest = AWSGameLiftClientFixture;
- TEST_F(AWSGameLiftJoinSessionActivityTest, BuildAWSGameLiftCreatePlayerSessionRequest_Call_GetExpectedResult)
- {
- AWSGameLiftJoinSessionRequest request;
- request.m_playerData = "dummyPlayerData";
- request.m_playerId = "dummyPlayerId";
- request.m_sessionId = "dummySessionId";
- auto awsRequest = JoinSessionActivity::BuildAWSGameLiftCreatePlayerSessionRequest(request);
- EXPECT_TRUE(strcmp(awsRequest.GetPlayerData().c_str(), request.m_playerData.c_str()) == 0);
- EXPECT_TRUE(strcmp(awsRequest.GetPlayerId().c_str(), request.m_playerId.c_str()) == 0);
- EXPECT_TRUE(strcmp(awsRequest.GetGameSessionId().c_str(), request.m_sessionId.c_str()) == 0);
- }
- TEST_F(AWSGameLiftJoinSessionActivityTest, BuildSessionConnectionConfig_Call_GetIpAddressAsDestinationResult)
- {
- Aws::GameLift::Model::PlayerSession playerSession;
- playerSession.SetIpAddress("dummyIpAddress");
- playerSession.SetPlayerSessionId("dummyPlayerSessionId");
- playerSession.SetPort(123);
- Aws::GameLift::Model::CreatePlayerSessionResult createPlayerSessionResult;
- createPlayerSessionResult.SetPlayerSession(playerSession);
- Aws::GameLift::Model::CreatePlayerSessionOutcome createPlayerSessionOutcome(createPlayerSessionResult);
- auto connectionConfig = JoinSessionActivity::BuildSessionConnectionConfig(createPlayerSessionOutcome);
- EXPECT_TRUE(strcmp(connectionConfig.m_dnsName.c_str(), "") == 0);
- EXPECT_TRUE(strcmp(connectionConfig.m_ipAddress.c_str(), playerSession.GetIpAddress().c_str()) == 0);
- EXPECT_TRUE(strcmp(connectionConfig.m_playerSessionId.c_str(), playerSession.GetPlayerSessionId().c_str()) == 0);
- EXPECT_TRUE(connectionConfig.m_port == playerSession.GetPort());
- }
- TEST_F(AWSGameLiftJoinSessionActivityTest, BuildSessionConnectionConfig_Call_GetDNSAsDestinationResult)
- {
- Aws::GameLift::Model::PlayerSession playerSession;
- playerSession.SetDnsName("gameliftunittest.amazongamelift.com");
- playerSession.SetIpAddress("dummyIpAddress");
- playerSession.SetPlayerSessionId("dummyPlayerSessionId");
- playerSession.SetPort(123);
- Aws::GameLift::Model::CreatePlayerSessionResult createPlayerSessionResult;
- createPlayerSessionResult.SetPlayerSession(playerSession);
- Aws::GameLift::Model::CreatePlayerSessionOutcome createPlayerSessionOutcome(createPlayerSessionResult);
- auto connectionConfig = JoinSessionActivity::BuildSessionConnectionConfig(createPlayerSessionOutcome);
- EXPECT_TRUE(strcmp(connectionConfig.m_dnsName.c_str(), playerSession.GetDnsName().c_str()) == 0);
- EXPECT_TRUE(strcmp(connectionConfig.m_ipAddress.c_str(), "") == 0);
- EXPECT_TRUE(strcmp(connectionConfig.m_playerSessionId.c_str(), playerSession.GetPlayerSessionId().c_str()) == 0);
- EXPECT_TRUE(connectionConfig.m_port == playerSession.GetPort());
- }
- TEST_F(AWSGameLiftJoinSessionActivityTest, ValidateJoinSessionRequest_CallWithBaseType_GetFalseResult)
- {
- AZ_TEST_START_TRACE_SUPPRESSION;
- auto result = JoinSessionActivity::ValidateJoinSessionRequest(Multiplayer::JoinSessionRequest());
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- EXPECT_FALSE(result);
- }
- TEST_F(AWSGameLiftJoinSessionActivityTest, ValidateJoinSessionRequest_CallWithEmptyPlayerId_GetFalseResult)
- {
- AWSGameLiftJoinSessionRequest request;
- request.m_sessionId = "dummySessionId";
- AZ_TEST_START_TRACE_SUPPRESSION;
- auto result = JoinSessionActivity::ValidateJoinSessionRequest(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- EXPECT_FALSE(result);
- }
- TEST_F(AWSGameLiftJoinSessionActivityTest, ValidateJoinSessionRequest_CallWithEmptySessionId_GetFalseResult)
- {
- AWSGameLiftJoinSessionRequest request;
- request.m_playerId = "dummyPlayerId";
- AZ_TEST_START_TRACE_SUPPRESSION;
- auto result = JoinSessionActivity::ValidateJoinSessionRequest(request);
- AZ_TEST_STOP_TRACE_SUPPRESSION(1); // capture 1 error message
- EXPECT_FALSE(result);
- }
- TEST_F(AWSGameLiftJoinSessionActivityTest, ValidateJoinSessionRequest_CallWithPlayerAndSessionId_GetTrueResult)
- {
- AWSGameLiftJoinSessionRequest request;
- request.m_playerId = "dummyPlayerId";
- request.m_sessionId = "dummySessionId";
- auto result = JoinSessionActivity::ValidateJoinSessionRequest(request);
- EXPECT_TRUE(result);
- }
|