Skip to content

Commit

Permalink
Added support for changing the options. (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
talesm committed Feb 24, 2016
1 parent 08163d6 commit a52c0f7
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 76 deletions.
15 changes: 11 additions & 4 deletions controller/MainController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,17 @@ class MainController
* @param name the budget name.
* @todo Return a BudgetView instead.
*/
virtual BudgetView getBudget(const std::string &name)
{
throw std::logic_error("Not implemented");
}
virtual BudgetView getBudget(const std::string &name) { throw std::logic_error("Not implemented"); }
/**
* @brief List all accounts
* @return some iterable container.
*/
virtual std::vector<std::string> listAccounts() const { throw std::logic_error("Not implemented"); }
/**
* @brief List of all categories
* @return some iterable container.
*/
virtual std::vector<std::string> listCategories() const { throw std::logic_error("Not implemented"); }
};
}

Expand Down
4 changes: 2 additions & 2 deletions orcamento.project
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"sourceDirectory": "$(ProjectPath)",
"generator": "MinGW Makefiles",
"buildType": "Debug",
"arguments": ["-D\"orca-build-standalone:BOOL=OFF\"", "-D\"orca-build-tests:BOOL=ON\""],
"arguments": ["-D\"orca-build-standalone:BOOL=OFF\"", "-D\"orca-build-tests:BOOL=ON\"", "-D\"BOOST_ROOT=$(Boost)\""],
"parentProject": ""
}]]]>
</Plugin>
Expand Down Expand Up @@ -275,7 +275,7 @@
</Compiler>
<Linker Options="" Required="yes"/>
<ResourceCompiler Options="" Required="no"/>
<General OutputFile="$(ConfigurationName)" IntermediateDirectory="./debug" Command="./$(ConfigurationName)/$(ConfigurationName).exe" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<General OutputFile="$(ConfigurationName)" IntermediateDirectory="./debug" Command="./$(ConfigurationName)/$(ConfigurationName).exe" CommandArguments="&quot;Scenario: ExecutionDetailPresenter edits&quot;" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
<![CDATA[]]>
</Environment>
Expand Down
4 changes: 2 additions & 2 deletions orcamento.workspace
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Project Name="test" Path="test.project" Active="No"/>
<Project Name="model" Path="model.project" Active="No"/>
<BuildMatrix>
<WorkspaceConfiguration Name="Debug" Selected="yes">
<WorkspaceConfiguration Name="Debug" Selected="no">
<Environment/>
<Project Name="orcamento" ConfigName="Debug"/>
<Project Name="test" ConfigName="Debug"/>
Expand All @@ -23,7 +23,7 @@
<Environment/>
<Project Name="orcamento" ConfigName="controller-test"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="presenter-test" Selected="no">
<WorkspaceConfiguration Name="presenter-test" Selected="yes">
<Environment/>
<Project Name="orcamento" ConfigName="presenter-test"/>
</WorkspaceConfiguration>
Expand Down
74 changes: 70 additions & 4 deletions presenter-test/ExecutionDetailPresenter-unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "ExecutionDetailPresenter.hpp"
#include "ExecutionView.hpp"
#include "stubs/ExecutionControllerStub.hpp"
#include <array>

struct ExecutionDetailPresenterFixture {
CallRecorder call_recorder;
Expand All @@ -19,6 +20,9 @@ struct ExecutionDetailPresenterFixture {
}
};
ExecutionDetailPresenter executionDetailPresenter{view};
array<string, 3> accounts{{"pocket", "bank", "savings"}};
array<string, 3> categories{{"ARTICUNO", "ZAPDOS", "MOLTRES"}};
array<string, 3> estimates{{"ESTIMATE1", "ESTIMATE2", "ESTIMATE3"}};
};

SCENARIO_METHOD(ExecutionDetailPresenterFixture,
Expand All @@ -39,19 +43,77 @@ SCENARIO_METHOD(ExecutionDetailPresenterFixture,
}
}

SCENARIO_METHOD(ExecutionDetailPresenterFixture,
"ExecutionDetailPresenter accounts",
"[presenter][execution-detail-presenter-class]")
{
GIVEN("A Properly initialized Execution Detail Presenter")
{
WHEN("The accounts is set")
{
executionDetailPresenter.accounts(begin(accounts), end(accounts));
THEN("See the accounts")
{
UserInputChecker uic("", "the accounts field is filled");
exec(executionDetailPresenter);
}
}
}
}

SCENARIO_METHOD(ExecutionDetailPresenterFixture,
"ExecutionDetailPresenter estimates",
"[presenter][execution-detail-presenter-class]")
{
GIVEN("A Properly initialized Execution Detail Presenter")
{
WHEN("The accunts is set")
{
executionDetailPresenter.estimates(begin(estimates), end(estimates));
THEN("See the estimates")
{
UserInputChecker uic("", "the estimates field is filled");
exec(executionDetailPresenter);
}
}
}
}

SCENARIO_METHOD(ExecutionDetailPresenterFixture,
"ExecutionDetailPresenter categories",
"[presenter][execution-detail-presenter-class]")
{
GIVEN("A Properly initialized Execution Detail Presenter")
{
WHEN("The categories is set")
{
executionDetailPresenter.categories(begin(categories), end(categories));
THEN("See the categories")
{
UserInputChecker uic("", "the categories field is filled");
exec(executionDetailPresenter);
}
}
}
}

SCENARIO_METHOD(ExecutionDetailPresenterFixture,
"ExecutionDetailPresenter edits",
"[presenter][execution-detail-presenter-class]")
{
GIVEN("A Properly initialized Execution Detail Presenter")
{
executionDetailPresenter.accounts(begin(accounts), end(accounts));
executionDetailPresenter.estimates(begin(estimates), end(estimates));
executionDetailPresenter.categories(begin(categories), end(categories));
WHEN("It sets the date")
{
THEN("It calls setDate()")
{
UserInputChecker uic("set date", "");
exec(executionDetailPresenter);
REQUIRE(call_recorder.has("setDate"));
REQUIRE(view.date != executionDetailPresenter.get().date);
}
}
WHEN("It sets the amount")
Expand All @@ -61,6 +123,7 @@ SCENARIO_METHOD(ExecutionDetailPresenterFixture,
UserInputChecker uic("set amount", "");
exec(executionDetailPresenter);
REQUIRE(call_recorder.has("setAmount"));
REQUIRE(view.amount != executionDetailPresenter.get().amount);
}
}
WHEN("It sets the operation")
Expand All @@ -70,6 +133,7 @@ SCENARIO_METHOD(ExecutionDetailPresenterFixture,
UserInputChecker uic("set operation", "");
exec(executionDetailPresenter);
REQUIRE(call_recorder.has("setOperation"));
REQUIRE(view.operation != executionDetailPresenter.get().operation);
}
}
WHEN("It sets the account")
Expand All @@ -79,6 +143,8 @@ SCENARIO_METHOD(ExecutionDetailPresenterFixture,
UserInputChecker uic("set account", "");
exec(executionDetailPresenter);
REQUIRE(call_recorder.has("setAccount"));
REQUIRE(executionDetailPresenter.get().account.size() > 0);
REQUIRE(view.account != executionDetailPresenter.get().account);
}
}
WHEN("It sets the estimate")
Expand All @@ -88,6 +154,8 @@ SCENARIO_METHOD(ExecutionDetailPresenterFixture,
UserInputChecker uic("set estimate", "");
exec(executionDetailPresenter);
REQUIRE(call_recorder.has("setEstimate"));
REQUIRE(executionDetailPresenter.get().estimate.size() > 0);
REQUIRE(view.estimate != executionDetailPresenter.get().estimate);
}
}
WHEN("It sets the category")
Expand All @@ -97,6 +165,8 @@ SCENARIO_METHOD(ExecutionDetailPresenterFixture,
UserInputChecker uic("set category", "");
exec(executionDetailPresenter);
REQUIRE(call_recorder.has("setCategory"));
REQUIRE(executionDetailPresenter.get().category.size() > 0);
REQUIRE(view.category != executionDetailPresenter.get().category);
}
}
}
Expand All @@ -118,7 +188,3 @@ SCENARIO_METHOD(ExecutionDetailPresenterFixture,
}
}
}
// TODO: Setting Accounts
// TODO: Setting Categories
// TODO: Setting Estimates
// TODO: Integrate with the ExecutionListPresenter and MainPresenter
6 changes: 4 additions & 2 deletions presenter-test/ExecutionListPresenter-unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ SCENARIO_METHOD(ExecutionListPresenterFixture,
WHEN("The user edits")
{
bool executeViewHandlerCalled = false;
executionListPresenter.editViewHandler([&executeViewHandlerCalled](auto &&){
executionListPresenter.editViewHandler([&executeViewHandlerCalled](auto &&v){
v.code *= 2;
executeViewHandlerCalled = true;
});
UserInputChecker uic("click on an execution, press [space] and confirm", "");
UserInputChecker uic("click on an execution, press [space] and confirm", "see if the code field changed");
THEN("The function editViewHandler() is called")
{
exec(host);
Expand All @@ -96,3 +97,4 @@ SCENARIO_METHOD(ExecutionListPresenterFixture,
}
}

//TODO Integrate with ExecutionDetail
70 changes: 35 additions & 35 deletions presenter-test/MainPresenter-unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,91 +214,91 @@ SCENARIO("Budget list manipulation", "[presenter][main-presenter-class]")
}
}

SCENARIO("Exectution List Manipulation", "[presenter][main-presenter-class]")
SCENARIO("MainPresenter tab summary", "[main-presenter-class][presenter][tabs]")
{
GIVEN("A MainPresenter with a file loaded")
{
CallRecorder callRecorder;
Manager manager = createManagerForTest(callRecorder);
MainPresenter mainPresenter{manager, "teste"};
WHEN("User clicks on Execution->New")
{
THEN("The ExecutionDetailPresenter shows up")
{
UserInputChecker uic("click at the menu Execution->New",
"the execution tab is selected and the dialog to edit an estimate shows up");
exec(mainPresenter);
}
}
WHEN("User clicks on Execution->Edit")
{
THEN("The ExecutionDetailPresenter shows up")
{
UserInputChecker uic("click at the menu Execution->Edit",
"the execution tab is selected and the dialog to edit an estimate shows up");
exec(mainPresenter);
}
}
WHEN("User clicks on Execution->Delete")
WHEN("Summary tab is selected")
{
THEN("The confirmation shows up")
THEN("Show the summary")
{
UserInputChecker uic("click at the menu Execution->Delete",
"c confirmation shows up and in yes case it removes the selected line");
UserInputChecker uic("Click the first tab", "the summary is shown");
exec(mainPresenter);
}
}
}
}

SCENARIO("MainPresenter tab summary", "[main-presenter-class][presenter][tabs]")
SCENARIO("MainPresenter tab estimates", "[main-presenter-class][presenter][tabs]")
{
GIVEN("A MainPresenter with a file loaded")
{
CallRecorder callRecorder;
Manager manager = createManagerForTest(callRecorder);
MainPresenter mainPresenter{manager, "teste"};
WHEN("Summary tab is selected")
WHEN("Estimates tab is selected")
{
THEN("Show the summary")
THEN("Show the estimates")
{
UserInputChecker uic("Click the first tab", "the summary is shown");
UserInputChecker uic("Click the second tab", "the estimates are shown");
exec(mainPresenter);
}
}
}
}

SCENARIO("MainPresenter tab estimates", "[main-presenter-class][presenter][tabs]")
SCENARIO("MainPresenter tab executions", "[main-presenter-class][presenter][tabs]")
{
GIVEN("A MainPresenter with a file loaded")
{
CallRecorder callRecorder;
Manager manager = createManagerForTest(callRecorder);
MainPresenter mainPresenter{manager, "teste"};
WHEN("Estimates tab is selected")
WHEN("Execution tab is selected")
{
THEN("Show the estimates")
THEN("Show the executions")
{
UserInputChecker uic("Click the second tab", "the estimates are shown");
UserInputChecker uic("Click the third tab", "the executions are shown");
exec(mainPresenter);
}
}
}
}

SCENARIO("MainPresenter tab executions", "[main-presenter-class][presenter][tabs]")
SCENARIO("Exectution List Manipulation", "[presenter][main-presenter-class]")
{
GIVEN("A MainPresenter with a file loaded")
{
CallRecorder callRecorder;
Manager manager = createManagerForTest(callRecorder);
MainPresenter mainPresenter{manager, "teste"};
WHEN("Execution tab is selected")
WHEN("User clicks on Execution->New")
{
THEN("Show the executions")
THEN("The ExecutionDetailPresenter shows up")
{
UserInputChecker uic("Click the third tab", "the executions are shown");
UserInputChecker uic("click at the menu Execution->New",
"the execution tab is selected and the dialog to edit an estimate shows up");
exec(mainPresenter);
}
}
WHEN("User clicks on Execution->Edit")
{
THEN("The ExecutionDetailPresenter shows up")
{
UserInputChecker uic("click at executions tab, select an execution and then click at the menu Execution->Edit",
"the execution tab is selected and the dialog to edit an estimate shows up");
exec(mainPresenter);
}
}
WHEN("User clicks on Execution->Delete")
{
THEN("The confirmation shows up")
{
UserInputChecker uic("click at executions tab, select an execution and then click at menu Execution->Delete",
"confirmation shows up and in yes case it removes the selected line");
exec(mainPresenter);
}
}
Expand Down
11 changes: 11 additions & 0 deletions presenter-test/stubs/MainControllerStub.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,15 @@ struct MainControllerStub : public MainController {
controller : [this]() -> unique_ptr<BudgetController> { return make_unique<BudgetControllerStub>(call_recorder); }
};
}

vector<string> listCategories() const override
{
ORCA_RECORD_CALL(call_recorder);
return {"Cat1", "Cat2", "Cat3"};
}
vector<string> listAccounts() const override
{
ORCA_RECORD_CALL(call_recorder);
return {"Acc1", "Acc2", "Acc3"};
}
};
3 changes: 2 additions & 1 deletion presenter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

find_package(Boost REQUIRED)
add_library(presenter
BudgetSummaryPresenter
EstimateDetailPresenter
Expand All @@ -13,6 +13,7 @@ add_library(presenter
target_include_directories(presenter
PUBLIC ../external/nana/include/
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${Boost_INCLUDE_DIR}
)

target_link_libraries(presenter
Expand Down
Loading

0 comments on commit a52c0f7

Please sign in to comment.