72 lines
2.1 KiB
C++
72 lines
2.1 KiB
C++
#include <gmock/gmock.h>
|
|
|
|
#include "mocks/SessionMock.hpp"
|
|
#include "mocks/widgets/AuthWidgetMock.hpp"
|
|
|
|
#include <Wt/Test/WTestEnvironment>
|
|
|
|
#include <eedb/EEDB.hpp>
|
|
#include <eedb/Session.hpp>
|
|
#include <eedb/db/connection.hpp>
|
|
#include <eedb/widgets/Theme.hpp>
|
|
|
|
class AuthPageFactory {
|
|
public:
|
|
MOCK_METHOD0(impl, eedb::AuthPage *());
|
|
auto operator()() {
|
|
return impl();
|
|
}
|
|
};
|
|
|
|
class HomePageFactory {
|
|
public:
|
|
MOCK_METHOD0(impl, eedb::HomePage *());
|
|
auto operator()() {
|
|
return impl();
|
|
}
|
|
};
|
|
|
|
using namespace testing;
|
|
|
|
class EedbApplicationTest : public Test {
|
|
public:
|
|
EedbApplicationTest() {
|
|
createApp();
|
|
}
|
|
|
|
void createApp() {
|
|
EXPECT_CALL(authPageFactory, impl()).WillOnce(Return(&authPage));
|
|
|
|
EXPECT_CALL(authPage, registerNeedVerification(_)).WillRepeatedly(Invoke(&authPage, &eedb::AuthPageMock::regNeedEmailWerification));
|
|
EXPECT_CALL(authPage, registerOnUserWeakLogin(_)).WillRepeatedly(Invoke(&authPage, &eedb::AuthPageMock::regWeakLogin));
|
|
EXPECT_CALL(authPage, registerOnUserStrongLogin(_)).WillRepeatedly(Invoke(&authPage, &eedb::AuthPageMock::regStrongLogin));
|
|
EXPECT_CALL(authPage, registerOnUserLogout(_)).WillRepeatedly(Invoke(&authPage, &eedb::AuthPageMock::regUserLogout));
|
|
EXPECT_CALL(authPage, setParent(Ne(nullptr)));
|
|
|
|
Wt::Test::WTestEnvironment env;
|
|
|
|
auto session = std::make_unique< eedb::SessionMock >();
|
|
EXPECT_CALL(*session, enviroment()).WillOnce(ReturnRef(env));
|
|
|
|
sut = new eedb::EEDB(std::move(session), [this]() { return authPageFactory(); }, [this]() { return homePageFactory(); });
|
|
}
|
|
|
|
protected:
|
|
AuthPageFactory authPageFactory;
|
|
HomePageFactory homePageFactory;
|
|
eedb::AuthPageMock authPage;
|
|
eedb::EEDB * sut;
|
|
};
|
|
|
|
TEST_F(EedbApplicationTest, createAuthPage) {}
|
|
|
|
TEST_F(EedbApplicationTest, strongLoginCreatesMainPage) {
|
|
EXPECT_CALL(homePageFactory, impl()).WillOnce(Return(nullptr));
|
|
authPage.notifyUserStrongLogin();
|
|
}
|
|
|
|
TEST_F(EedbApplicationTest, weakLoginCreatesMainPage) {
|
|
EXPECT_CALL(homePageFactory, impl()).WillOnce(Return(nullptr));
|
|
authPage.notifyUserWeakLogin();
|
|
}
|