function WorldTestSuite:TestCaseAddChairToWorld()
local result, errorInfo = World:AddEntity( "Chair" )
ASSERT( result, true, "Nie udalo sie postawic krzesla na swiecie.", errorInfo )
-- errorInfo jako 4 parametr to takie info techniczne - powod dla ktorego nie udalo sie tego zrobic
end
function World:AddEntity( name )
-- rejestrujemy polaczenie z baza danych - bedziemy ja pytac czy liczba elementow na swiecie sie zwiekszyla czy nie
local createDatabaseConnectionResult, createDatabaseConnectionErrorInfo = CreateDatabaseConnection()
if ( createDatabaseConnectionResult == false OR createDatabaseConnectionErrorInfo ~= nil ) then
return false, createErrocreateDatabaseConnectionErrorInforInfo
end
-- ta metoda jets w chuj fake, chcialem poprostu aby wygladalo jakby mialo sens
local currentEntitiesCount, currentEntitiesCountErrorInfo = GetIntFromDatabase( "entitiesCount" )
if ( currentEntitiesCountErrorInfo ~= nil ) then
return false, currentEntitiesCountErrorInfo
end
local createResult, createErrorMessage = ask_engine_to_do_something( "createEntity(" .. name .. ")" )
if ( createResult == false OR createErrorMessage ~= nil ) then
return false, createErrorMessage
end
-- sprawdzamy ponownie po utworzeniu krzesla liczbe entitek
local entitiesCountAfter, entitiesCountAfterErrorInfo = GetIntFromDatabase( "entitiesCount" )
if ( entitiesCountAfterErrorInfo ~= nil ) then
return false, entitiesCountAfterErrorInfo
end
if ( currentEntitiesCount >= entitiesCountAfter ) then
return false, "Liczba entitek po dodaniu nowej jest rowna " .. entitiesCountAfter .. " i nie jest wieksza od poczatkowej liczby " .. currentEntitiesCount
end
local closeDatabaseConnectionResult, closeDatabaseConnectionErrorInfo = CloseDatabaseConnection()
if ( closeDatabaseConnectionResult == false OR closeDatabaseConnectionErrorInfo ~= nil ) then
return false, closeDatabaseConnectionErrorInfo
end
end
Replies to Re: Re: Untitled
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}