#include "user_controller_tests.h"
#include "../../controllers/user_controller/user_controller.h"
#include "../../repository/repository.h"
#include "../../domain/trench.h"
#include "../../exceptions/exceptions.h"

#include<assert.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>

void test_user_controller(void){
    Repository* repo = new Repository();
    Repository* shoppingRepo = new Repository();
    UserController* userController = new UserController(repo,shoppingRepo);
    Trench* trench1 = new Trench(1,"red",100,100,"photo");
    Trench* trench2 = new Trench(2,"blue",200,2,"photo");
    Trench* trench3 = new Trench(3,"green",300,100,"photo");
    Trench* trench1_copy = new Trench(1,"red",100,100,"photo");
    Trench* trench2_copy = new Trench(2,"blue",200,100,"photo");
    repo->add(trench1);
    repo->add(trench2);
    repo->add(trench3);
    userController->addProductToShoppingList(trench1_copy);
    userController->addProductToShoppingList(trench1_copy);
    userController->addProductToShoppingList(trench1_copy);
    assert(userController->shoppingListTotal()==300);
    userController->emptyShoppingList();
    assert(userController->shoppingListTotal()==0);
    userController->addProductToShoppingList(trench2_copy);
    userController->addProductToShoppingList(trench2_copy);
    assert(userController->shoppingListTotal()==400);
    userController->buyShoppingList();
    assert(userController->shoppingListTotal()==0);
    assert(userController->getTrenchCarousel(-1).size()==2);
    assert(userController->getTrenchCarousel(2).size()==0);
    delete trench1_copy;
    delete trench2_copy;
    delete userController;
    delete repo;
    
}