feat: add Test for sendValue

This commit is contained in:
Mathis 2023-04-24 15:49:16 +02:00
parent 36bdb86343
commit 884169e745
3 changed files with 17 additions and 7 deletions

View File

@ -10,6 +10,7 @@ void setup() {
RUN_TEST(TestWifiBeginNotConnected); RUN_TEST(TestWifiBeginNotConnected);
RUN_TEST(TestConnectAPI); RUN_TEST(TestConnectAPI);
// RUN_TEST(TestConnectAPIFailed); // RUN_TEST(TestConnectAPIFailed);
RUN_TEST(TestSendValue);
UNITY_END(); UNITY_END();

View File

@ -4,6 +4,7 @@
void TestWifiBeginConnected(); void TestWifiBeginConnected();
void TestWifiBeginNotConnected(); void TestWifiBeginNotConnected();
void TestConnectAPI(); void TestConnectAPI();
// void TestConnectAPIFailed(); void TestConnectAPIFailed();
void TestSendValue();
#endif #endif

View File

@ -29,13 +29,21 @@ void TestConnectAPI() {
TEST_ASSERT_EQUAL_MESSAGE(true, api->connect(), "Not Connected"); TEST_ASSERT_EQUAL_MESSAGE(true, api->connect(), "Not Connected");
} }
// void TestConnectAPIFailed() { //FIXME: boucle inf when connection failed
// API* api = new API("Carl", "toto", API_HOST); void TestConnectAPIFailed() {
API* api = new API("Carl", "toto", API_HOST);
// Serial1.begin(MONITOR_SPEED); Serial1.begin(MONITOR_SPEED);
// api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1); api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
// TEST_ASSERT_EQUAL_MESSAGE(false, api->connect(), "Connected"); TEST_ASSERT_EQUAL_MESSAGE(false, api->connect(), "Connected");
// } }
//Testing SendValue function //Testing SendValue function
void TestSendValue() {
API* api = new API(USER_NAME, USER_PASSWORD, API_HOST);
Serial1.begin(MONITOR_SPEED);
api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
TEST_ASSERT_EQUAL_MESSAGE(true, api->sendValue("30", "gdnuxl0wlgurtj3", "W", true), "Not Connected to server");
}