Hello GitHub

This commit is contained in:
Howard Wolosky
2019-01-28 16:24:37 -08:00
parent 456fe5e355
commit c13b8a099e
822 changed files with 276650 additions and 75 deletions

View File

@@ -0,0 +1,56 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "pch.h"
#include "CurrencyHttpClient.h"
#include "CalcViewModel\Common\NetworkManager.h"
using namespace CalculatorApp::DataLoaders;
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::System::UserProfile;
using namespace Windows::Web::Http;
// Generic responses so unit tests will pass.
static constexpr auto STATIC_DATA_RESPONSE = LR"([{"CountryCode":"USA","CountryName":"United States","CurrencyCode":"USD","CurrencyName":"Dollar","CurrencySymbol":"$"},{"CountryCode":"EUR","CountryName":"Europe","CurrencyCode":"EUR","CurrencyName":"Euro","CurrencySymbol":""}])";
static constexpr auto ALL_RATIOS_RESPONSE = LR"([{"An":"USD","Ch":0,"Pc":0,"Rt":1},{"An":"EUR","Ch":0.003803,"Pc":0.4149,"Rt":0.920503,"Yh":0.9667,"Yl":0.86701}])";
CurrencyHttpClient::CurrencyHttpClient()
{
}
String^ CurrencyHttpClient::GetRawStaticDataResponse()
{
return StringReference(STATIC_DATA_RESPONSE);
}
String^ CurrencyHttpClient::GetRawAllRatiosDataResponse()
{
return StringReference(ALL_RATIOS_RESPONSE);
}
IAsyncOperationWithProgress<String^, HttpProgress>^ CurrencyHttpClient::GetCurrencyMetadata()
{
return ref new MockAsyncOperationWithProgress(StringReference(STATIC_DATA_RESPONSE));
}
IAsyncOperationWithProgress<String^, HttpProgress>^ CurrencyHttpClient::GetCurrencyRatios()
{
return ref new MockAsyncOperationWithProgress(StringReference(ALL_RATIOS_RESPONSE));
}
MockAsyncOperationWithProgress::MockAsyncOperationWithProgress(String^ result) :
m_result(result)
{
}
HResult MockAsyncOperationWithProgress::ErrorCode::get()
{
HResult okayResult;
okayResult.Value = S_OK;
return okayResult;
}

View File

@@ -0,0 +1,75 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "CalcViewModel\DataLoaders\ICurrencyHttpClient.h"
namespace CalculatorApp
{
namespace DataLoaders
{
class CurrencyHttpClient : public ICurrencyHttpClient
{
public:
CurrencyHttpClient();
static Platform::String^ GetRawStaticDataResponse();
static Platform::String^ GetRawAllRatiosDataResponse();
// ICurrencyHttpClient
void SetSourceCurrencyCode(Platform::String^ sourceCurrencyCode) override {}
void SetResponseLanguage(Platform::String^ responseLanguage) override {}
virtual Windows::Foundation::IAsyncOperationWithProgress<Platform::String^, Windows::Web::Http::HttpProgress>^ GetCurrencyMetadata() override;
virtual Windows::Foundation::IAsyncOperationWithProgress<Platform::String^, Windows::Web::Http::HttpProgress>^ GetCurrencyRatios() override;
// ICurrencyHttpClient
};
public ref class MockAsyncOperationWithProgress sealed :
public Windows::Foundation::IAsyncOperationWithProgress<Platform::String^, Windows::Web::Http::HttpProgress>
{
public:
MockAsyncOperationWithProgress(Platform::String^ result);
// IAsyncInfo
virtual property Windows::Foundation::HResult ErrorCode
{
Windows::Foundation::HResult get();
}
virtual property unsigned int Id
{
unsigned int get() { return 128u; }
}
virtual property Windows::Foundation::AsyncStatus Status
{
Windows::Foundation::AsyncStatus get() { return Windows::Foundation::AsyncStatus::Completed; }
}
virtual void Cancel() {}
virtual void Close() {}
// IAsyncInfo
// IAsyncOperationWithProgress
virtual property Windows::Foundation::AsyncOperationProgressHandler<Platform::String^, Windows::Web::Http::HttpProgress>^ Progress
{
Windows::Foundation::AsyncOperationProgressHandler<Platform::String^, Windows::Web::Http::HttpProgress>^ get() { return nullptr; }
void set(Windows::Foundation::AsyncOperationProgressHandler<Platform::String^, Windows::Web::Http::HttpProgress>^ handler) {}
}
virtual property Windows::Foundation::AsyncOperationWithProgressCompletedHandler<Platform::String^, Windows::Web::Http::HttpProgress>^ Completed
{
Windows::Foundation::AsyncOperationWithProgressCompletedHandler<Platform::String^, Windows::Web::Http::HttpProgress>^ get() { return nullptr; }
void set(Windows::Foundation::AsyncOperationWithProgressCompletedHandler<Platform::String^, Windows::Web::Http::HttpProgress>^ handler) {}
}
virtual Platform::String^ GetResults() { return m_result; }
// IAsyncOperationWithProgress
private:
Platform::String^ m_result;
};
}
}