Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 46 additions & 4 deletions tdd_intro/homework/04_weather_client/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ class FakeWeatherServer : public IWeatherServer

std::vector<std::string> GetRequests()
{
return m_requests;
std::vector<std::string> result;
result.swap(m_requests);
return result;
}
};

Expand All @@ -149,9 +151,21 @@ class WeatherClient : public IWeatherClient
GetWeatherForADay(server, date);
return 0.0;
}
virtual double GetMaximumTemperature(IWeatherServer& server, const std::string& date){return 0.0;}
virtual double GetAverageWindDirection(IWeatherServer& server, const std::string& date){return 0.0;}
virtual double GetMaximumWindSpeed(IWeatherServer& server, const std::string& date){return 0.0;}
virtual double GetMaximumTemperature(IWeatherServer& server, const std::string& date)
{
GetWeatherForADay(server, date);
return 0.0;
}
virtual double GetAverageWindDirection(IWeatherServer& server, const std::string& date)
{
GetWeatherForADay(server, date);
return 0.0;
}
virtual double GetMaximumWindSpeed(IWeatherServer& server, const std::string& date)
{
GetWeatherForADay(server, date);
return 0.0;
}
private:
std::vector<std::string> GetWeatherForADay(IWeatherServer& server, const std::string& date)
{
Expand Down Expand Up @@ -188,3 +202,31 @@ TEST(WeatherClient, ClientSends4TimesForMinTemp)
client.GetMinimumTemperature(server, s_testDate);
ASSERT_EQ(expectedRequests, server.GetRequests());
}
TEST(WeatherClient, FourRequestsForAnyClientCall)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это должны были быть раздельные тесты)

{
std::vector<std::string> expectedRequests =
{
CreateRequest(s_testDate,s_3hours),
CreateRequest(s_testDate,s_9hours),
CreateRequest(s_testDate,s_15hours),
CreateRequest(s_testDate,s_21hour)
};
WeatherClient client;
FakeWeatherServer server;

client.GetAverageTemperature(server, s_testDate);
ASSERT_EQ(expectedRequests, server.GetRequests());

client.GetMaximumTemperature(server, s_testDate);
ASSERT_EQ(expectedRequests, server.GetRequests());

client.GetAverageWindDirection(server, s_testDate);
ASSERT_EQ(expectedRequests, server.GetRequests());

client.GetAverageWindDirection(server, s_testDate);
ASSERT_EQ(expectedRequests, server.GetRequests());

client.GetMaximumWindSpeed(server, s_testDate);
ASSERT_EQ(expectedRequests, server.GetRequests());

}