Delimiter //
/**
 * test for LOADER_ENTRIES_MAP_CURRENCY_NOTPROVIDED()
 * 
 * @author Jean-François
 */
Drop Procedure If Exists TEST_LOADER_ENTRIES_MAP_CURRENCY_NOTPROVIDED//
Create Procedure TEST_LOADER_ENTRIES_MAP_CURRENCY_NOTPROVIDED()
Begin


    -- table
    Call LOADER_TEST_MOCK_ENTRIES_CLEAN();
    Call LOADER_TEST_MOCK_ENTRIES_PUSH(1, Concat('ID_ENTRIES_NEW = 1, CURRENCY = ''''') , 1, Null);
    Call LOADER_TEST_MOCK_ENTRIES_PUSH(2, Concat('ID_ENTRIES_NEW = 2, CURRENCY = ''XXX''') , 2, Null);

    -- Entity
    Call LOADER_TEST_MOCK_INFO_CLEAN();
    Call LOADER_TEST_MOCK_INFO_PUSH('ID_ENTITIES', 1);

    Call LOADER_TEST_MOCK_BUSINESS_CLEAN('ENTITIES');
    Call LOADER_TEST_MOCK_BUSINESS_PUSH('ENTITIES', 
            'ID_ENTITIES = 1
            , DF_CURRENCIES_ID_DF_CURR = 1
            , ADMIN_ID_ADMIN = 1
            , CONT_BUSINESS_ID_CONT_BUSINESS = 1
            , ENTITIES_LOCK_STATE = 0
            , ENTITIES_CODE = 1'
    );

    -- tested procedure
    Call LOADER_ENTRIES_MAP_CURRENCY_NOTPROVIDED(1);

--     -- assertions
    Call utAssert_eq('When currency is not provided, row receives the currency of the entity'
        , 1
        , (Select DF_CURRENCIES_ID_DF_CURRENCIES From LOADER_ENTRIES Where ID_LOADER_ENTRIES = 1)
    );
    Call utAssert_eq('When currency provided, nothing is changed here'
        , Null
        , (Select DF_CURRENCIES_ID_DF_CURRENCIES From LOADER_ENTRIES Where ID_LOADER_ENTRIES = 2)
    );

    -- cleans
    Call LOADER_TEST_MOCK_INFO_CLEAN();
    Call LOADER_TEST_MOCK_BUSINESS_CLEAN('ENTITIES');
    Call LOADER_TEST_MOCK_ENTRIES_CLEAN();

End//
Delimiter ;