2023-01-26 09:51:04 -05:00
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
# pragma once
# ifndef S3_EXAMPLES_S3_GTESTS_H
# define S3_EXAMPLES_S3_GTESTS_H
# include <aws/core/Aws.h>
# include <memory>
# include <gtest/gtest.h>
class MockHttpClient ;
class MockHttpClientFactory ;
namespace AwsDocTest {
class MyStringBuffer : public std : : stringbuf {
int underflow ( ) override ;
} ;
class Cognito_GTests : public testing : : Test {
protected :
void SetUp ( ) override ;
void TearDown ( ) override ;
static void SetUpTestSuite ( ) ;
static void TearDownTestSuite ( ) ;
static Aws : : String preconditionError ( ) ;
void AddCommandLineResponses ( const std : : vector < std : : string > & responses ) ;
// s_clientConfig must be a pointer because the client config must be initialized
// after InitAPI.
static std : : unique_ptr < Aws : : Client : : ClientConfiguration > s_clientConfig ;
private :
2023-03-01 15:59:42 -05:00
bool suppressStdOut ( ) ;
2023-01-26 09:51:04 -05:00
static Aws : : SDKOptions s_options ;
std : : stringbuf m_coutBuffer ; // Used to silence cout.
std : : streambuf * m_savedBuffer = nullptr ;
MyStringBuffer m_cinBuffer ;
std : : streambuf * m_savedInBuffer = nullptr ;
} ;
class MockHTTP {
public :
MockHTTP ( ) ;
virtual ~ MockHTTP ( ) ;
void addResponseWithBody ( const std : : string & body ) ;
private :
std : : shared_ptr < MockHttpClient > mockHttpClient ;
std : : shared_ptr < MockHttpClientFactory > mockHttpClientFactory ;
std : : shared_ptr < Aws : : Http : : HttpRequest > requestTmp ;
} ;
} // AwsDocTest
# endif //S3_EXAMPLES_S3_GTESTS_H