Browse Source
Merge branch 'feature/balance-operations' of https://gitlab2.informatik.hs-fulda.de/fdai7057/bankmanagement-system into feature/balance-operations
remotes/origin/feature/loan-eligibility
Merge branch 'feature/balance-operations' of https://gitlab2.informatik.hs-fulda.de/fdai7057/bankmanagement-system into feature/balance-operations
remotes/origin/feature/loan-eligibility
Shivam Chaudhary
2 years ago
6 changed files with 182 additions and 3 deletions
-
4src/CustomerData.txt
-
55src/sendmoney.c
-
10src/sendmoney.h
-
45src/updateCustomerAccountBalance.c
-
2src/updateCustomerAccountBalance.h
-
69tests/test_sendmoney.c
@ -0,0 +1,55 @@ |
|||||
|
#include "sendMoney.h" |
||||
|
#include "depositMoney.c" |
||||
|
#include "withdrawMoney.c" |
||||
|
|
||||
|
bool sendMoney(int customerID){ |
||||
|
float availableAccountBalance=getAvailableAccountBalance(customerID); |
||||
|
float amountToSend; |
||||
|
int recID; |
||||
|
printf("\nYou have %.2f€ in your account. How much would you like to send?\n",availableAccountBalance); |
||||
|
scanf("%f",&amountToSend); |
||||
|
if(amountToSend>0 && amountToSend<availableAccountBalance){ |
||||
|
printf("\nYour input was %.2f€. Please enter the recipient id.\n",amountToSend); |
||||
|
scanf("%d",&recID); |
||||
|
if(recID>1000){ |
||||
|
bool recExists=checkCustomerExists(recID); |
||||
|
if(recExists){ |
||||
|
if(recID==customerID){ |
||||
|
printf("\nYou cannot send money to yourself. Aborting. \n"); |
||||
|
return false; |
||||
|
} |
||||
|
else{ |
||||
|
if(withdrawSpecificAmount(customerID, amountToSend)){ |
||||
|
if(depositSpecificAmount(recID, amountToSend)){ |
||||
|
printf("\nYou have successfuly transfered %.2f€ to [%d]",amountToSend,recID); |
||||
|
return true; |
||||
|
} |
||||
|
else{ |
||||
|
printf("\nSomething went wrong with the transfer. Please contact staff."); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
}else{ |
||||
|
if(withdrawSpecificAmount(customerID, amountToSend)){ |
||||
|
printf("\nYou have successfuly transfered %.2f€ to [%d]",amountToSend,recID); |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
printf("\nThe ID you have entered is not valid. Aborting. \n"); |
||||
|
} |
||||
|
|
||||
|
}else{ |
||||
|
//error |
||||
|
return false; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
// int main(){ |
||||
|
// sendMoney(1234); |
||||
|
// return 0; |
||||
|
// } |
@ -0,0 +1,10 @@ |
|||||
|
#ifndef SENDMONEY_H |
||||
|
#define SENDMONEY_H |
||||
|
#include <stdlib.h> |
||||
|
#include <stdio.h> |
||||
|
#include <stdbool.h> |
||||
|
#include <string.h> |
||||
|
|
||||
|
bool sendMoney(int customerID); |
||||
|
|
||||
|
#endif // SENDMONEY_H |
@ -0,0 +1,69 @@ |
|||||
|
#ifdef TEST |
||||
|
#include <sendmoney.h> |
||||
|
#include <unity.h> |
||||
|
|
||||
|
void setUp(void) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
void tearDown(void) |
||||
|
{ |
||||
|
} |
||||
|
// hier wird die Methode checkAccount getestet |
||||
|
void test_sendmoney_NeedToImplement(void) |
||||
|
{ |
||||
|
// Arrage |
||||
|
|
||||
|
int accountNumber = 1234567; |
||||
|
int accountNumber2 = 5555557; |
||||
|
|
||||
|
// hier soll false sein |
||||
|
int accountNumber3 = 53323; |
||||
|
int accountNumber4 = 34342; |
||||
|
bool expected; |
||||
|
bool expected2; |
||||
|
bool expected3; |
||||
|
bool expected4; |
||||
|
// Act |
||||
|
|
||||
|
expected = checkAccount(accountNumber); |
||||
|
expected2 = checkAccount(accountNumber2); |
||||
|
expected3 = checkAccount(accountNumber3); |
||||
|
expected4 = checkAccount(accountNumber4); |
||||
|
|
||||
|
// Assert |
||||
|
|
||||
|
TEST_ASSERT_TRUE(expected); |
||||
|
TEST_ASSERT_TRUE(expected2); |
||||
|
TEST_ASSERT_FALSE(expected3); |
||||
|
TEST_ASSERT_FALSE(expected4); |
||||
|
} |
||||
|
|
||||
|
// hier wird die Methode getAvailableAccountBalance()getestet |
||||
|
void test_getAvailableAccountBalance(void) |
||||
|
{ |
||||
|
|
||||
|
// Arrage |
||||
|
|
||||
|
double expected1 = 24.0; |
||||
|
int length = 2; |
||||
|
|
||||
|
// Act |
||||
|
|
||||
|
double result = getAvailableAccountBalance(length); |
||||
|
|
||||
|
// Assert |
||||
|
TEST_ASSERT_EQUAL(expected1, result); |
||||
|
} |
||||
|
// hier wird die Methode getAmount() getestet |
||||
|
void test_getAmount(void) |
||||
|
{ |
||||
|
// Arrage |
||||
|
float expected = 500.1; |
||||
|
|
||||
|
float result = getAmount(expected); |
||||
|
|
||||
|
TEST_ASSERT_EQUAL(expected, result); |
||||
|
} |
||||
|
|
||||
|
#endif // TEST |
Write
Preview
Loading…
Cancel
Save
Reference in new issue