diff --git a/tdd_intro/homework/01_leap_year/test.cpp b/tdd_intro/homework/01_leap_year/test.cpp index 4f186c8b..95c428b8 100644 --- a/tdd_intro/homework/01_leap_year/test.cpp +++ b/tdd_intro/homework/01_leap_year/test.cpp @@ -13,3 +13,46 @@ If your language provides a method in the standard library that does this look-u */ #include + +bool IsLeap(size_t year) +{ + if (year % 400 != 0 && year % 100 == 0) + { + return false; + } + + return year % 4 == 0; +} + +TEST(IsLeap, ReturnFalseForOddYears) +{ + ASSERT_FALSE(IsLeap(1901)); +} + +TEST(IsLeap, ReturnTrueIfDevisibleBy400) +{ + ASSERT_TRUE(IsLeap(1600)); +} + +TEST(IsLeap, ReturnTrueIfDevisibleBy4AndNotDevisibleBy100) +{ + ASSERT_TRUE(IsLeap(1804)); +} + +TEST(IsLeap, ReturnFalseIfDevisibleBy100AndNotDivisibleBy400) +{ + ASSERT_FALSE(IsLeap(1900)); +} + +TEST(IsLeap, AcceptanceTest) +{ + ASSERT_TRUE(IsLeap(4)); + ASSERT_TRUE(IsLeap(1604)); + ASSERT_TRUE(IsLeap(400)); + ASSERT_TRUE(IsLeap(2000)); + + ASSERT_FALSE(IsLeap(1)); + ASSERT_FALSE(IsLeap(1701)); + ASSERT_FALSE(IsLeap(1700)); + ASSERT_FALSE(IsLeap(1900)); +} diff --git a/tdd_intro/homework/02_ternary_numbers/test.cpp b/tdd_intro/homework/02_ternary_numbers/test.cpp index 17503028..9ed37c1a 100644 --- a/tdd_intro/homework/02_ternary_numbers/test.cpp +++ b/tdd_intro/homework/02_ternary_numbers/test.cpp @@ -1,4 +1,5 @@ #include +#include /* Convert a ternary number, represented as a string (e.g. '102012'), to its decimal equivalent using first principles. @@ -16,3 +17,77 @@ The last place in a ternary number is the 1's place. The second to last is the 3 If your language provides a method in the standard library to perform the conversion, pretend it doesn't exist and implement it yourself. */ + +int ConvertToTernary(const std::string& number) +{ + const size_t inputSize = number.size(); + size_t result = 0; + + for (size_t i = 1; i <= inputSize; ++i) + { + const char current = number[inputSize - i]; + if (!isdigit(current)) + { + return 0; + } + + std::string curCharStr; + curCharStr += current; + + int curNumber = 0; + if ((curNumber = std::atoi(curCharStr.c_str())) > 2) + { + return 0; + } + + result += static_cast(pow(3, i - 1) * curNumber); + } + + return result; +} + +TEST (ConvertToTernary, ReturnsZeroIfPassInvalidParameter) +{ + EXPECT_EQ(ConvertToTernary("a"), 0); +} + +TEST (ConvertToTernary, SuccesfullyConvertStringWithSizeEquals1) +{ + EXPECT_EQ(ConvertToTernary("1"), 1); +} + +TEST (ConvertToTernary, SuccesfullyConvertStringWithSizeEquals1_2) +{ + EXPECT_EQ(ConvertToTernary("2"), 2); +} + +TEST (ConvertToTernary, SuccesfullyConvertStringWithSizeEquals2) +{ + EXPECT_EQ(ConvertToTernary("10"), 3); +} + +TEST (ConvertToTernary, ReturnsZeroIfPassInvalidParameter_2) +{ + EXPECT_EQ(ConvertToTernary("1a2b"), 0); +} + +TEST (ConvertToTernary, ReturnsZeroIfPassInvalidParameter_3) +{ + EXPECT_EQ(ConvertToTernary("53"), 0); +} + +TEST (ConvertToTernary, AcceptanceTests) +{ + EXPECT_EQ(ConvertToTernary("202"), 20); + EXPECT_EQ(ConvertToTernary("2201"), 73); + EXPECT_EQ(ConvertToTernary("12"), 5); + + EXPECT_EQ(ConvertToTernary("abc"), 0); + EXPECT_EQ(ConvertToTernary("d1hj"), 0); + + EXPECT_EQ(ConvertToTernary("4356"), 0); + EXPECT_EQ(ConvertToTernary("7"), 0); + + EXPECT_EQ(ConvertToTernary("a31"), 0); + EXPECT_EQ(ConvertToTernary("zr5"), 0); +} diff --git a/tdd_intro/homework/03_bank_ocr/test.cpp b/tdd_intro/homework/03_bank_ocr/test.cpp index a01540b9..80f775b0 100644 --- a/tdd_intro/homework/03_bank_ocr/test.cpp +++ b/tdd_intro/homework/03_bank_ocr/test.cpp @@ -195,3 +195,207 @@ const Display s_display123456789 = { " _ _ _ _ _ _ _ ", " | _| _||_||_ |_ ||_||_|", " ||_ _| | _||_| ||_| _|" }; + +/* + * test list : + * throws if empty file + * throws if not each line 27 long + * throws if line count mod 3 != 0 + * throws in case of invalid number form + * successful conversation (one id) + * successful conversation (two id's) + * successful conversation (unlimited size) +*/ + +class EmptyFileError : public std::runtime_error +{ +public: + EmptyFileError(const char* what) + : std::runtime_error(what) + {} +}; + +class LenghtError : public std::runtime_error +{ +public: + LenghtError(const char* what) + : std::runtime_error(what) + {} +}; + +class LineCountError : public std::runtime_error +{ +public: + LineCountError(const char* what) + : std::runtime_error(what) + {} +}; + +class NumberFormatError : public std::runtime_error +{ +public: + NumberFormatError(const char* what) + : std::runtime_error(what) + {} +}; + +std::vector SplitByLines(const std::string& strToSplit) +{ + std::stringstream ss(strToSplit); + std::string item; + std::vector splittedStrings; + while (std::getline(ss, item, '\n')) + { + if (item.size() != 27) + { + throw LenghtError("OOPS"); + } + + splittedStrings.push_back(item); + } + return splittedStrings; +} + +bool operator == (const Digit& lhs, const Digit& rhs) +{ + bool equals = true; + for (size_t i = 0; i < 3; ++i) + { + equals = equals && lhs.lines[i] == rhs.lines[i]; + } + + return equals; +} + +size_t GetDigit(const Digit& digit) +{ + if (digit == s_digit0) + { + return 0; + } + if (digit == s_digit1) + { + return 1; + } + if (digit == s_digit2) + { + return 2; + } + if (digit == s_digit3) + { + return 3; + } + if (digit == s_digit4) + { + return 4; + } + if (digit == s_digit5) + { + return 5; + } + if (digit == s_digit6) + { + return 6; + } + if (digit == s_digit7) + { + return 7; + } + if (digit == s_digit8) + { + return 8; + } + if (digit == s_digit9) + { + return 9; + } + + throw NumberFormatError("OOPS"); +} +std::string GetNumberFromThreeStrings(const std::string& first, const std::string& second, const std::string& third) +{ + std::stringstream stream; + size_t pos = 0; + while (pos < 27) + { + Digit digit; + digit.lines[0] = first.substr(pos, 3); + digit.lines[1] = second.substr(pos, 3); + digit.lines[2] = third.substr(pos, 3); + stream << GetDigit(digit); + pos += 3; + } + + return stream.str(); +} + +std::vector SplitByNumbers(const std::vector& lines) +{ + std::vector numbers; + for (size_t i = 0; i < lines.size() / 3; ++i) + { + std::string firstLine = lines[3*i]; + std::string secondLine = lines[3*i + 1]; + std::string thirdLine = lines[3*i + 2]; + numbers.push_back(GetNumberFromThreeStrings(firstLine, secondLine, thirdLine)); + } + + return numbers; +} + +std::vector ParseFile(const std::string& file) +{ + if (file.empty()) + { + throw EmptyFileError("empty file"); + } + + std::vector lines = SplitByLines(file); + + if (lines.size() % 3 != 0) + { + throw LineCountError("line count error"); + } + + return SplitByNumbers(lines); +} + +TEST(ParseFile, ThrowsIfEmptyFile) +{ + ASSERT_THROW(ParseFile(""), EmptyFileError); +} + +TEST(ParseFile, ThrowsIfNotEachLine27Long) +{ + ASSERT_THROW(ParseFile("abc"), LenghtError); +} + +TEST(ParseFile, ThrowsIfLineCountMod3NotZero) +{ + std::string file(27, '_'); + file = file + '\n' + file; + ASSERT_THROW(ParseFile(file), LineCountError); +} + +TEST(SplitByNumbers, ThrowsInCaseOfInvalidNumberForm) +{ + std::string file(27, '_'); + file = file + '\n' + file + '\n' + file; + std::vector files {file, file, file}; + ASSERT_THROW(SplitByNumbers(files), NumberFormatError); +} + +TEST(SplitByNumbers, SuccessfulSplit) +{ + std::vector lines = {s_display123456789.lines[0], s_display123456789.lines[1], s_display123456789.lines[2]}; + auto result = SplitByNumbers(lines); + ASSERT_EQ(result.size(), 1); + ASSERT_EQ(result[0], "123456789"); +} + +TEST(ParseFile, SuccessfulParse) +{ + std::string file = s_display123456789.lines[0] + "\n" + s_display123456789.lines[1] + "\n" + s_display123456789.lines[2]; + std::vector result = ParseFile(file); + ASSERT_EQ(result[0], "123456789"); +} diff --git a/tdd_intro/homework/04_weather_client/test.cpp b/tdd_intro/homework/04_weather_client/test.cpp index 346ea809..1e7a04c5 100644 --- a/tdd_intro/homework/04_weather_client/test.cpp +++ b/tdd_intro/homework/04_weather_client/test.cpp @@ -46,6 +46,7 @@ Each line means "" : "": #include #include +#include struct Weather { @@ -68,6 +69,22 @@ class IWeatherServer virtual std::string GetWeather(const std::string& request) = 0; }; +class FakeServer : public IWeatherServer +{ +public: + virtual std::string GetWeather(const std::string& request) override + { + return m_fakeResults.count(request) ? m_fakeResults[request] : ""; + } +private: + std::map m_fakeResults = { + {"31.08.2018;03:00", "20;181;5.1"}, + {"31.08.2018;09:00", "23;204;4.9"}, + {"31.08.2018;15:00", "33;193;4.3"}, + {"31.08.2018;21:00", "26;179;4.5"} + }; +}; + // Implement this interface class IWeatherClient { @@ -79,3 +96,238 @@ class IWeatherClient virtual double GetAverageWindDirection(IWeatherServer& server, const std::string& date) = 0; virtual double GetMaximumWindSpeed(IWeatherServer& server, const std::string& date) = 0; }; + +class WeatherClient : public IWeatherClient +{ +public: + virtual double GetAverageTemperature(IWeatherServer& server, const std::string& date) override + { + std::vector responses; + GetResponcesFromDate(date, server, responses); + + double result = 0; + for (const auto& response : responses) + { + if (response.empty()) + { + throw std::runtime_error(""); + } + + size_t pos = response.find(";"); + result += std::atof(std::string(response.begin(), response.begin() + pos).c_str()); + } + + return result / responses.size(); + } + virtual double GetMinimumTemperature(IWeatherServer& server, const std::string& date) override + { + return GetExtremumTemperatureByComparator(server, date, [](double left, double right) + { + return left < right; + }); + } + virtual double GetMaximumTemperature(IWeatherServer& server, const std::string& date) override + { + return GetExtremumTemperatureByComparator(server, date, [](double left, double right) + { + return left > right; + }); + } + virtual double GetAverageWindDirection(IWeatherServer& server, const std::string& date) override + { + std::vector responses; + GetResponcesFromDate(date, server, responses); + + double result = 0; + + for (const auto& response : responses) + { + if (response.empty()) + { + throw std::runtime_error(""); + } + + const size_t pos1 = response.find(";"); + const size_t pos2 = response.find(";", pos1 + 1); + result += std::atof(std::string(response.begin() + pos1 + 1, response.begin() + pos2).c_str()); + } + + return result / responses.size(); + } + virtual double GetMaximumWindSpeed(IWeatherServer& server, const std::string& date) override + { + std::vector responses; + GetResponcesFromDate(date, server, responses); + + double result = 0; + + for (const auto& response : responses) + { + if (response.empty()) + { + throw std::runtime_error(""); + } + + const size_t pos1 = response.find(";"); + const size_t pos2 = response.find(";", pos1 + 1); + double temp = std::atof(std::string(response.begin() + pos2 + 1, response.end()).c_str()); + + if (temp > result) + { + result = temp; + } + } + + return result; + } + +private: + + void GetResponcesFromDate(const std::string& date, IWeatherServer& server, + std::vector& responses) + { + responses.push_back(server.GetWeather(date + ";03:00")); + responses.push_back(server.GetWeather(date + ";09:00")); + responses.push_back(server.GetWeather(date + ";15:00")); + responses.push_back(server.GetWeather(date + ";21:00")); + } + + double GetExtremumTemperatureByComparator(IWeatherServer& server, const std::string& date, std::function comp) + { + std::vector responses; + GetResponcesFromDate(date, server, responses); + + double result = 0; + bool initialized = false; + + for (const auto& response : responses) + { + if (response.empty()) + { + throw std::runtime_error(""); + } + + const size_t pos = response.find(";"); + const double temp = std::atof(std::string(response.begin(), response.begin() + pos).c_str()); + + if (!initialized) + { + result = temp; + initialized = true; + continue; + } + + if (comp(temp, result)) + { + result = temp; + } + } + + return result; + } +}; + +/*Test list: + * all methods throws in case of invalid date format + * all methods return right value :) +*/ + +TEST (WeatherClient, GAT_ThrowsIfInvalidDateFormat) +{ + WeatherClient client; + FakeServer server; + EXPECT_THROW(client.GetAverageTemperature(server, ""), std::runtime_error); +} + +TEST(WeatherClient, GMT_ThrowsIfInvalidDateFormat) +{ + WeatherClient client; + FakeServer server; + EXPECT_THROW(client.GetMaximumTemperature(server, ""), std::runtime_error); +} + +TEST(WeatherClient, GMnT_ThrowsIfInvalidDateFormat) +{ + WeatherClient client; + FakeServer server; + EXPECT_THROW(client.GetMinimumTemperature(server, ""), std::runtime_error); +} + +TEST(WeatherClient, GAWD_ThrowsIfInvalidDateFormat) +{ + WeatherClient client; + FakeServer server; + EXPECT_THROW(client.GetAverageWindDirection(server, ""), std::runtime_error); +} + +TEST(WeatherClient, GMWD_ThrowsIfInvalidDateFormat) +{ + WeatherClient client; + FakeServer server; + EXPECT_THROW(client.GetMaximumWindSpeed(server, ""), std::runtime_error); +} + +TEST(WeatherClient, GAT_Succesful) +{ + WeatherClient client; + FakeServer server; + + const std::string date("31.08.2018"); + + const double expectedValue = static_cast(20 + 23 + 33 + 26) / 4; + const double error = std::abs(expectedValue - client.GetAverageTemperature(server, date)); + + EXPECT_TRUE(error < 0.01); +} + +TEST(WeatherClient, GMnT_Succesful) +{ + WeatherClient client; + FakeServer server; + + const std::string date("31.08.2018"); + + const double expectedValue = 20; + const double error = std::abs(expectedValue - client.GetMinimumTemperature(server, date)); + + EXPECT_TRUE(error < 0.01); +} + +TEST(WeatherClient, GMT_Succesful) +{ + WeatherClient client; + FakeServer server; + + const std::string date("31.08.2018"); + + const double expectedValue = 33; + const double error = std::abs(expectedValue - client.GetMaximumTemperature(server, date)); + + EXPECT_TRUE(error < 0.01); +} + +TEST(WeatherClient, GAWD_Succesful) +{ + WeatherClient client; + FakeServer server; + + const std::string date("31.08.2018"); + + const double expectedValue = static_cast(181 + 204 + 193 + 179) / 4; + const double error = std::abs(expectedValue - client.GetAverageWindDirection(server, date)); + + EXPECT_TRUE(error < 0.01); +} + +TEST(WeatherClient, GMWD_Succesful) +{ + WeatherClient client; + FakeServer server; + + const std::string date("31.08.2018"); + + const double expectedValue = 5.1; + const double error = std::abs(expectedValue - client.GetMaximumWindSpeed(server, date)); + + EXPECT_TRUE(error < 0.01); +} diff --git a/tdd_intro/homework/05_word_wrapp/test.cpp b/tdd_intro/homework/05_word_wrapp/test.cpp index 77e47210..4eea25b5 100644 --- a/tdd_intro/homework/05_word_wrapp/test.cpp +++ b/tdd_intro/homework/05_word_wrapp/test.cpp @@ -36,14 +36,20 @@ WrappedStrings WrapString(const std::string& str, size_t wrapLength) for(size_t i = 0; i < str.length(); i += wrapLength) { std::string cur = str.substr(i, wrapLength); - if (cur.back() == ' ') + + while (!cur.empty() && cur.back() == ' ') { cur.pop_back(); } - if(!cur.empty() && cur.front() == ' ') + if (!cur.empty() && cur.front() == ' ') { - cur = cur.substr(1); + auto it = std::find_if_not(cur.cbegin(), cur.cend(), [](char elem) + { + return elem == ' '; + }); + + cur.erase(cur.begin(), it); } if(!cur.empty()) @@ -94,3 +100,31 @@ TEST(WrapString, StringWrappedBySeveralWhitespace) WrappedStrings expected = {"12", "34"}; ASSERT_EQ(expected, WrapString("12 34", 3)); } + +TEST(WrapString, StringWrappedBySeveralWhitespace2) +{ + WrappedStrings expected = {"12", "34"}; + ASSERT_EQ(expected, WrapString("12 34", 3)); +} + +TEST(WrapString, StringWrappedBySeveralWhitespace3) +{ + WrappedStrings expected = {"123", "34"}; + ASSERT_EQ(expected, WrapString("123 34", 4)); +} + +TEST(WrapString, OnlyWhiteSpaces) +{ + WrappedStrings expected; + ASSERT_EQ(expected, WrapString(" ", 4)); + ASSERT_EQ(expected, WrapString(" ", 1)); +} + +TEST(WrapString, Acceptance) +{ + WrappedStrings expected = {"1234567", "34567", "12 456"}; + ASSERT_EQ(expected, WrapString("1234567 34567 12 456", 7)); + + WrappedStrings expected2 = {"abcd", "efg", "qwe", "rty", "asdf", "gh"}; + ASSERT_EQ(expected2, WrapString("abcd efg qwerty asdf gh", 4)); +} diff --git a/tdd_intro/homework/06_coffee/test.cpp b/tdd_intro/homework/06_coffee/test.cpp index 33b9093e..a07aaf41 100644 --- a/tdd_intro/homework/06_coffee/test.cpp +++ b/tdd_intro/homework/06_coffee/test.cpp @@ -40,7 +40,10 @@ enum Cup enum Coffee { - Americano + Americano, + Cappuccino, + Latte, + Marochino }; class MockSourceOfIngredients : public ISourceOfIngredients @@ -59,16 +62,67 @@ class MockSourceOfIngredients : public ISourceOfIngredients class CoffeeMachine { public: - CoffeeMachine(ISourceOfIngredients& source) : m_source(source) + CoffeeMachine(ISourceOfIngredients& source) + : m_source(source) { } - void CreateCoffee(const Cup cup, const Coffee coffee) + + void CreateCoffee(Cup cup, Coffee coffee) { - m_source.AddCoffee(0); - m_source.SetCupSize(0); - m_source.AddWater(0, 0); + switch (coffee) + { + case (Americano) : + PerformAmericano(cup); + break; + case (Cappuccino) : + PerformCappucino(cup); + break; + case (Latte) : + PerformLatte(cup); + break; + case (Marochino) : + PerformMarochino(cup); + break; + } } + +private: + void PerformAmericano(Cup cup) + { + const double factor = cup == Normal ? 1 : 1.4; + m_source.AddCoffee(75 * factor); + m_source.SetCupSize(100 * factor); + m_source.AddWater(25 * factor, 60); + } + + void PerformCappucino(Cup cup) + { + const double factor = cup == Normal ? 1 : 1.4; + m_source.SetCupSize(100 * factor); + m_source.AddMilkFoam(33 * factor); + m_source.AddCoffee(33 * factor); + m_source.AddMilk(33 * factor); + } + + void PerformLatte(Cup cup) + { + const double factor = cup == Normal ? 1 : 1.4; + m_source.SetCupSize(100 * factor); + m_source.AddMilkFoam(25 * factor); + m_source.AddCoffee(50 * factor); + m_source.AddMilk(25 * factor); + } + + void PerformMarochino(Cup cup) + { + const double factor = cup == Normal ? 1 : 1.4; + m_source.SetCupSize(100 * factor); + m_source.AddMilkFoam(25 * factor); + m_source.AddCoffee(25 * factor); + m_source.AddChocolate(25 * factor); + } + private: ISourceOfIngredients& m_source; }; @@ -87,33 +141,105 @@ class CoffeeMachine // 4. Check parameters // 5. Same for each recipe -TEST(CoffeeMachine, CoffemachineIsHere) +//- americano: water & coffee 1:3 Water temp 60C +TEST(CoffeeMachine, Americano) { MockSourceOfIngredients si; CoffeeMachine cm(si); + + EXPECT_CALL(si, AddCoffee(75)).Times(1); + EXPECT_CALL(si, SetCupSize(100)).Times(1); + EXPECT_CALL(si, AddWater(25, 60)).Times(1); + + cm.CreateCoffee(Cup::Normal, Coffee::Americano); } -TEST(CoffeeMachine, CallsImportantThings) +TEST(CoffeeMachine, Cappuccino) { MockSourceOfIngredients si; CoffeeMachine cm(si); - EXPECT_CALL(si, AddCoffee(::testing::_)).Times(1); - EXPECT_CALL(si, SetCupSize(::testing::_)).Times(1); - EXPECT_CALL(si, AddWater(::testing::_, ::testing::_)).Times(1); + EXPECT_CALL(si, AddCoffee(33)).Times(1); + EXPECT_CALL(si, AddMilk(33)).Times(1); + EXPECT_CALL(si, AddMilkFoam(33)).Times(1); + EXPECT_CALL(si, SetCupSize(100)).Times(1); - cm.CreateCoffee(Cup::Normal, Coffee::Americano); + cm.CreateCoffee(Cup::Normal, Coffee::Cappuccino); } -//- americano: water & coffee 1:3 Water temp 60C -TEST(CoffeeMachine, Americano) +TEST(CoffeeMachine, Latte) { MockSourceOfIngredients si; CoffeeMachine cm(si); - EXPECT_CALL(si, AddCoffee(75)).Times(1); + EXPECT_CALL(si, AddCoffee(50)).Times(1); + EXPECT_CALL(si, AddMilk(25)).Times(1); + EXPECT_CALL(si, AddMilkFoam(25)).Times(1); EXPECT_CALL(si, SetCupSize(100)).Times(1); - EXPECT_CALL(si, AddWater(25, 60)).Times(1); - cm.CreateCoffee(Cup::Normal, Coffee::Americano); + cm.CreateCoffee(Cup::Normal, Coffee::Latte); +} + +TEST(CoffeeMachine, Marochino) +{ + MockSourceOfIngredients si; + CoffeeMachine cm(si); + + EXPECT_CALL(si, AddCoffee(25)).Times(1); + EXPECT_CALL(si, AddChocolate(25)).Times(1); + EXPECT_CALL(si, AddMilkFoam(25)).Times(1); + EXPECT_CALL(si, SetCupSize(100)).Times(1); + + cm.CreateCoffee(Cup::Normal, Coffee::Marochino); +} + +TEST(CoffeeMachine, BigAmericano) +{ + MockSourceOfIngredients si; + CoffeeMachine cm(si); + + EXPECT_CALL(si, AddCoffee(105)).Times(1); + EXPECT_CALL(si, SetCupSize(140)).Times(1); + EXPECT_CALL(si, AddWater(35, 60)).Times(1); + + cm.CreateCoffee(Cup::Big, Coffee::Americano); +} + +TEST(CoffeeMachine, BigCappuccino) +{ + MockSourceOfIngredients si; + CoffeeMachine cm(si); + + EXPECT_CALL(si, AddCoffee(46)).Times(1); + EXPECT_CALL(si, AddMilk(46)).Times(1); + EXPECT_CALL(si, AddMilkFoam(46)).Times(1); + EXPECT_CALL(si, SetCupSize(140)).Times(1); + + cm.CreateCoffee(Cup::Big, Coffee::Cappuccino); +} + +TEST(CoffeeMachine, BigLatte) +{ + MockSourceOfIngredients si; + CoffeeMachine cm(si); + + EXPECT_CALL(si, AddCoffee(70)).Times(1); + EXPECT_CALL(si, AddMilk(35)).Times(1); + EXPECT_CALL(si, AddMilkFoam(35)).Times(1); + EXPECT_CALL(si, SetCupSize(140)).Times(1); + + cm.CreateCoffee(Cup::Big, Coffee::Latte); +} + +TEST(CoffeeMachine, BigMarochino) +{ + MockSourceOfIngredients si; + CoffeeMachine cm(si); + + EXPECT_CALL(si, AddCoffee(35)).Times(1); + EXPECT_CALL(si, AddChocolate(35)).Times(1); + EXPECT_CALL(si, AddMilkFoam(35)).Times(1); + EXPECT_CALL(si, SetCupSize(140)).Times(1); + + cm.CreateCoffee(Cup::Big, Coffee::Marochino); }