|
| 1 | +#include <gmock/gmock.h> |
| 2 | +#include <rest/domain/PricePlan.h> |
| 3 | +#include <rest/controller/MeterReadingController.h> |
| 4 | + |
| 5 | +using ::testing::Eq; |
| 6 | + |
| 7 | +TEST(PricePlanTest, GetEnergySupplierShouldReturnTheEnergySupplierGivenInTheConstructor) { |
| 8 | + const std::string energy_supplier = "Energy Supplier Name"; |
| 9 | + |
| 10 | + PricePlan p("", energy_supplier, 0, {}); |
| 11 | + |
| 12 | + EXPECT_THAT(p.getEnergySupplier(), energy_supplier); |
| 13 | +} |
| 14 | + |
| 15 | +TEST(PricePlanTest, GetPriceShouldReturnTheBasePriceGivenAnOrdinaryDateTime) { |
| 16 | + auto time = detail::fromRfc3339("2021-09-30T06:42:15.725202Z"); |
| 17 | + PricePlan::PeakTimeMultiplier peak_time_multiplier(PricePlan::PeakTimeMultiplier::DayOfWeek::WEDNESDAY, 10); |
| 18 | + PricePlan price_plan("", "", 1, {peak_time_multiplier}); |
| 19 | + |
| 20 | + auto price = price_plan.getPrice(time); |
| 21 | + |
| 22 | + EXPECT_THAT(price, 1); |
| 23 | +} |
| 24 | + |
| 25 | +TEST(PricePlanTest, GetPriceShouldReturnAnExceptionPriceGivenExceptionalDateTime) { |
| 26 | + auto time = detail::fromRfc3339("2021-09-29T06:42:15.725202Z"); |
| 27 | + PricePlan::PeakTimeMultiplier peak_time_multiplier(PricePlan::PeakTimeMultiplier::DayOfWeek::WEDNESDAY, 10); |
| 28 | + PricePlan price_plan("", "", 1, {peak_time_multiplier}); |
| 29 | + |
| 30 | + auto price = price_plan.getPrice(time); |
| 31 | + |
| 32 | + EXPECT_THAT(price, 10); |
| 33 | +} |
| 34 | + |
| 35 | +TEST(PricePlanTest, GetPriceShouldReceiveMultipleExceptionalDateTimes) { |
| 36 | + auto time = detail::fromRfc3339("2021-09-29T06:42:15.725202Z"); |
| 37 | + PricePlan::PeakTimeMultiplier peak_time_multiplier(PricePlan::PeakTimeMultiplier::DayOfWeek::WEDNESDAY, 10); |
| 38 | + PricePlan::PeakTimeMultiplier another_peak_time_multiplier(PricePlan::PeakTimeMultiplier::DayOfWeek::THURSDAY, 10); |
| 39 | + PricePlan price_plan("", "", 1, {peak_time_multiplier, another_peak_time_multiplier}); |
| 40 | + |
| 41 | + auto price = price_plan.getPrice(time); |
| 42 | + |
| 43 | + EXPECT_THAT(price, 10); |
| 44 | +} |
0 commit comments